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
Share on other sites

Stilll get a error.

 

Heres the full code.

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

The error comes up on the $query line.

Link to comment
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
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')");

Link to comment
Share on other sites

Again, what error are you getting, and try my example

I am not getting a error any more, it just doesn't send the data to the database when $strings are inserted. Which is why i asked if you could supply a full demonstration doing it.

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.