Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: database empty query
04-21-2013, 03:23 AM #1
- Join Date
- Feb 2007
- Thanked 1 Time in 1 Post
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
$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 #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
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.
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');