eugene2009 Posted November 18, 2009 Share Posted November 18, 2009 What is the proper wat to retrieve the variable in the mysql_query? I am having tons of trouble getting this little code to work. Please help $id = $_GET['id']; $result = mysql_query("SELECT * FROM comments WHERE id ='$id' "); $row = mysql_fetch_assoc($result); echo 'The customers name is, '.$row['name'].' and he made a purchase on, '.$row['date'].'.<BR>' ; Please help me. Thank you Link to comment https://forums.phpfreaks.com/topic/181943-get-method/ Share on other sites More sharing options...
Alex Posted November 18, 2009 Share Posted November 18, 2009 Besides the fact that it's vulnerable to mysql injections (Which you can correct by escaping $id with mysql_real_escape_string()) I don't see anything immediately wrong with that code. Exactly what isn't working? Link to comment https://forums.phpfreaks.com/topic/181943-get-method/#findComment-959695 Share on other sites More sharing options...
merylvingien Posted November 18, 2009 Share Posted November 18, 2009 $id = $_GET['id']; $result = mysql_query("SELECT * FROM comments WHERE id ='$id' "); $row = mysql_fetch_assoc($result); echo "The customers name is,". "{$row['name']}". "and he made a purchase on,". "{$row['date']}". "<BR>"; Link to comment https://forums.phpfreaks.com/topic/181943-get-method/#findComment-959712 Share on other sites More sharing options...
robert_gsfame Posted November 18, 2009 Share Posted November 18, 2009 What is the proper wat to retrieve the variable in the mysql_query? I am having tons of trouble getting this little code to work. Please help $id = $_GET['id']; $result = mysql_query("SELECT * FROM comments WHERE id =[b]'$id' "[/b]); $row = mysql_fetch_assoc($result); echo 'The customers name is, '.$row['name'].' and he made a purchase on, '.$row['date'].'.<BR>' ; Please help me. Thank you The code is correct but check WHERE id ='$id' ", erase the space between ' and " Link to comment https://forums.phpfreaks.com/topic/181943-get-method/#findComment-959790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.