Forum Moderators: coopster
Please help!
I'm trying to work through the examples in Luke Welling and Laura Thomson's text, "PHP and MySQL Web Development," though with some minor modifications like additional form variables. Yet I can't get them to work, notably the following 2:
1) For one application, I get the following error message:
parse error, unexpected T_CONSTANT_ENCAPSED_STRING
for this line:
$result = mysql_query("INSERT INTO user VALUES ('$username', '$password', '$first', '$last', '$email')");
(If you have the book, it refers to listing 24.9 on pg. 487).
I have also tried it where instead of
$password,
it's
password('$password'),
2) For the other application, I get this error message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
for the following code:
...
$query = 'select * from user '
."where name='$username' "
." and pass=password('$password')";
$result = mysql_query($query, $db_conn);
echo $result;
if (mysql_fetch_array($result) >0 )
{
// if they are in the database register the user id
$HTTP_SESSION_VARS['valid_user'] = $username;
}
}
(FYI, This is on page 226, Listing 10.2 of the same text).
Thank you!
$query = mysql_query('select * from user WHERE name='$username' AND pass=password('$password')') or die(mysql_error());
if (mysql_num_rows($query)>0)
{
//blah blah
}
dc
[edited by: dreamcatcher at 2:13 am (utc) on Nov. 19, 2004]
The error for the 1st application (the one with the parse error message) was indeed higher up. I didn't state a variable correctly. Now I can move on to the rest of the website!
For the 2nd application, I'm working on getting the database connection.
Again, thanks for everything!