Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Getting erros when posting data to MYSQL database via PHP

Codes here !

Moderators: macek, egami, gesf

Getting erros when posting data to MYSQL database via PHP

Postby jyounde2013 » Sat Sep 21, 2013 6:56 pm

New records are being inserted into the table when I check on the MYSQL Server but on the browser I keep getting this result: "Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in"

Below is my code that has resulted in the above stated error:

<html xmlns="" lang="en" xml:lang="en" >
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Searching inventory table</title>

<h1>Searching inventory table</h1>

<form action="modified.php" method="post" name="modify" id="modify">
<label>Make: <input type="text" name="make" id="make"> <br></label>
<label>Model: <input type="text" name="model" id="model"> <br></label>
<label>Price: <input type="text" name="price" id="price"> <br></label>
<label>Quantity: <input type="text" name="quantity" id="quantity"> <br></label>

<input type="submit" name="submit" value="add" />

<hr />

if(isset($_POST['make']) && isset($_POST['model']) && isset($_POST['price']) && isset($_POST['quantity']))
$DBConnect = @mysqli_connect("", "s2055899","gritt2013", "s2055899_db")
Or die ("<p>Unable to connect to the database server.</p>". "<p>Error code ". mysqli_connect_errno().": ". mysqli_connect_error()). "</p>";

// set up the SQL query string - we will retrieve the whole record that matches the name

$SQLstring = "INSERT INTO inventory (make, model, price, quantity)
VALUES ('$_POST[make]','$_POST[model]','$_POST[price]','$_POST[quantity]')";

$queryResult = @mysqli_query($DBConnect, $SQLstring)
Or die ("<p>Unable to query the inventory table.</p>"."<p>Error code ". mysqli_errno($DBConnect). ": ".mysqli_error($DBConnect)). "</p>";

echo "<h2>updated content of inventory table</h2>";
echo "<table width='100%' border='1'>";
echo "<th>Make</th><th>Model</th><th>Price</th><th>Quantity</th>";
$row = mysqli_fetch_row($queryResult);

while ($row) {
echo "<tr><td>{$row[1]}</td>";
echo "<td>{$row[2]}</td>";
echo "<td>{$row[3]}</td>";
echo "<td>{$row[4]}</td></tr>";
$row = mysqli_fetch_row($queryResult);
echo "</table>";



New php-forum User
New php-forum User
Posts: 1
Joined: Sat Sep 21, 2013 6:49 pm

Re: Getting erros when posting data to MYSQL database via PH

Postby johnj » Wed Oct 02, 2013 6:33 am

1).make sure $queryResult is returning the right result

2).remove the "@" symbol so that the code can throw errors
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.