Page 1 of 1

Little problem... help?

Posted: Mon Nov 18, 2002 4:43 pm
by Jim
I'm sure this should be obvious to me, but I don't see where the problem is.

This is the code:

Code: Select all

//Insert Users and Information
if($_POSTї'submit']) {


//Error in this line
$sql = "INSERT into IamJim_users(user_name, password, user_email) values('$_POSTї'user_name']' , '$_POSTї'password']' , '$_POSTї'user_email']')";


$query = mysql_query($sql);
	if(!$query) {
		echo mysql_error();
		exit;
		}

And...

The error:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /usr/local/plesk/apache/vhosts/empiregaming.net/httpdocs/iamjim/php/login/register.php on line 7


Thanks for help!

silly qoutes

Posted: Mon Nov 18, 2002 4:56 pm
by phpScott
I think it has to do how you are quoting things.

I lucky enough that my host doesn't force me to use that $_POST['variableName'] syntax yet.

try some thing like this.

Code: Select all

//Insert Users and Information
if($_POSTї'submit']) {


//Error in this line
$sql = "INSERT into IamJim_users(user_name, password, user_email) values(''$_POSTї'user_name']'' ,\ '$_POSTї'password']'' , ''$_POSTї'user_email']'')";


$query = mysql_query($sql);
   if(!$query) {
      echo mysql_error();
      exit;
      }
I don't know if backslashing those quotes will work but that looks like the problem when you string was getting parsed it was quoting around
'$_POST['
Which of course isn't what you wanted.

I know another wizbang php guy or gal out there will answers this in no time.

phpScott

Posted: Mon Nov 18, 2002 5:09 pm
by mydimension
phpScott had the right idea but is solution is incorrect. when using arrays inside strings you need to use curly brackets ( {} ) around the entire variable. like so:

Code: Select all

$sql = "INSERT into IamJim_users(user_name, password, user_email) values('{$_POSTї'user_name']}' , '{$_POSTї'password']}' , '{$_POSTї'user_email']}')";
that should do the trick.

Count the Curles please..!

Posted: Tue Nov 19, 2002 5:27 am
by abdul
Did the problem get solved..?. If not please count the number of curly braces ({..}). You have got two of them opened and one closed (I assume that this is the complete code).

Posted: Tue Nov 19, 2002 6:02 am
by volka

Code: Select all

echo "$_POSTїpassword]";
without any errors/warnings
http://www.php.net/manual/en/language.t ... ng.parsing