0

Hi I'm just trying to input two string variables into 2 fields of a database that are VarChars.

$name = "jear";
$pass = "jartt2";

$query = 'INSERT INTO `user` (`id`, `name`, `password`, `char_name`) VALUES (NULL, '$name', '$pass', 'test')';
$result = mysql_query($query);

This is the snippet of code that I'm trying to do. The database is connecting successfully and grabbing the table successfully. The error I get says:


Parse error: syntax error, unexpected T_STRING in /hermes/web10/b2810/moo.*****/*****/****** on line 14

I asterisked out the parts to my server. The file it is describing is the one that all the code is in, there are no includes or external docs being used.

Any help would be great! Thanks :)

Edited by jeeter19: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jeeter19
0

Change your quotes from ' to " surrounding your query;

$query = "INSERT INTO `user` (`id`, `name`, `password`, `char_name`) VALUES (NULL, '$name', '$pass', 'test')";
0

Thank you, it works exactly how it should now. I appreciate the help bud!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.