problem with code... Looks right but ways theres an error
Posted: Tue May 12, 2009 7:52 pm
i have a problem with my code. the error is this
but my line 1 is "<?php"
so i don 't know whats wrong
heres the code i'm using
Code: Select all
Error: You have an error IN your SQL syntax; CHECK the manual that corresponds to your MySQL server version for the RIGHT syntax to USE near '' at line 1
so i don 't know whats wrong
heres the code i'm using
Code: Select all
<?php
include '../login/dbc.php';
//first open connection to your database
$id = mysql_real_escape_string($_GET['id']); //catch the id number from url, store it and escape slashes from possible attack.
$takeuser = mysql_query("SELECT * FROM users WHERE id='$id' LIMIT 1"); //Right now script check id number from url against the database
if (mysql_num_rows($takeuser) < 1) { //checks if we have that id number in our database
echo "Error, Please Try Again"; //inform the user that we found 0 result
} else { //or if we found some
while ($row=mysql_fetch_array($takeuser)) { //Taking the result set
$sql="UPDATE friends SET activated = '1' WHERE id = '{$row['id']}' AND friend_id={$row['friend_id']}";
if (!mysql_query($sql,$link))
{
die('Error: ' . mysql_error());
}
} //closing the loop
} //closing the "if" statement
mysql_close($link); //and then we close connection
?>