Jump to content

Insert query problem?


axx5

Recommended Posts

$query =  "INSERT INTO Test VALUES (5," . $INFO1 . "," $INFO2 . "," . $INFO3 . "," . $INFO4 . "," . $INFO5)

Any idea why i get this error when adding this query? (the error comes after the connection has been made so the file does connect to the database, there must be though a problem with how its formatted?

Link to comment
https://forums.phpfreaks.com/topic/164621-insert-query-problem/
Share on other sites

How come it works with this though?

 

mysql_query("INSERT INTO `Test`.`user` (`id`, `name`, `password`, `ip`, `date`, `registered`) VALUES (NULL, 				                  'test', 'test', 'test', 'test', 'test 'test', 'test')", $c);

 

But if i adjust this even a little bit it doesn't work. why does this above example work yet this doesn't?

 

mysql_query("INSERT INTO" . $webdbname . "`user` (`id`, `name`, `password`, `ip`, `date`, `registered`) VALUES (NULL," .                   $sname . "," . $spassword . "," . $sip . "," . $date)", $c);[/code]

 

Link to comment
https://forums.phpfreaks.com/topic/164621-insert-query-problem/#findComment-868477
Share on other sites

You're not putting quotes around the value strings;

 

<?php
$mysql = mysql_connect("127.0.0.1", "root", "")
$query =  mysql_query("INSERT INTO Test VALUES (5, '$INFO1', '$INFO2', '$INFO3', '$INFO4', '$INFO5')");

That fixes it but then if i add quotes on

'date("Y:m:d")'

it doesn't work, ideas?

Link to comment
https://forums.phpfreaks.com/topic/164621-insert-query-problem/#findComment-868548
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.