||04-21-2013 03:23 AM
database empty query
I'm trying to write some values to my database, however it seems to fail since I'm getting the following error when I want to insert a record:
Warning: mysqli_query() [function.mysqli-query]: Empty query in
I hope someone can tell me what I'm doing wrong.
$con=mysqli_connect($db_host, $db_username, $db_password, $db_database);
echo "Failed to connect to MySQL: " . mysqli_connect_error();
$sql=mysqli_query($con,"INSERT INTO myproduct (product, model, price, quantity) VALUES ('hi', 'hixxx', '34', '99999')");
die('Error: ' . mysqli_error($con));
||04-21-2013 04:01 AM
You haven't done anything to verify your query.
The answer is simple, the query has failed. Standard check of
mysqli_error($con); will tell you the cause.
This is also not doable:
if (!mysqli_query($con,$sql)) . If the first one fails, that would trigger the same error as posted, if it was successful it will trigger an error on an incorrect argument datatype. You simply cannot query a query resultset.
|All times are GMT +1. The time now is 12:46 PM.
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.