Jump to content

query error


truck7758

Recommended Posts

can anyone see whats wrong with this query:

 

<?
$supp = $_POST["supp"];

$supp = addslashes($supp);

// Connecting, selecting database
$mysqli = new mysqli('host','username','password');
      $mysqli->select_db('orders');

// Performing SQL query
$result = $mysqli->query("SELECT * FROM supplier where `name` = '".$supp."'");

while($line = $result->fetch_assoc()) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
	if (empty($col_value)) {
		echo "\t\t<td> </td>\n";
	} else {
		echo "\t\t<td>$col_value</td>\n";
	}
    }
    echo "\t</tr>\n";
}
// Free resultset
mysqli_free_result($result);
// Closing connection
$mysqli->close();

?>

 

Thanks,

Mike

Link to comment
https://forums.phpfreaks.com/topic/98297-query-error/
Share on other sites

I don't see anything wrong. What error are you getting?

 

Try changing this line:

$result = $mysqli->query("SELECT * FROM supplier where `name` = '".$supp."'");

to

$result = $mysqli->query("SELECT * FROM supplier where `name` = '".$supp."'")
  or die("Query error: ".$mysqli->error);

 

Link to comment
https://forums.phpfreaks.com/topic/98297-query-error/#findComment-503003
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.