Little problem... help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Little problem... help?

Post 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!
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

silly qoutes

Post 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
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post 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.
abdul
Forum Newbie
Posts: 24
Joined: Thu Nov 14, 2002 7:35 am

Count the Curles please..!

Post 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).
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

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