rastaman46 Posted April 6, 2012 Share Posted April 6, 2012 Hello again here is my code but its dont work correct $super = $_GET['video_id']; $filmai = $TSUE['TSUE_Database']->query("SELECT rasta_cinema.video_id, rasta_cinema.name, rasta_cinema.description, rasta_cinema.video_name, rasta_cinema.thumb_image FROM rasta_cinema WHERE video_id = $super LIMIT 1"); error im get is Database Error! Please try again later or contact an Administrator. (1064) 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 'LIMIT 1' at line 1 SELECT rasta_cinema.video_id, rasta_cinema.name, rasta_cinema.description, rasta_cinema.video_name, rasta_cinema.thumb_image FROM rasta_cinema WHERE video_id = LIMIT 1 Thanks Link to comment https://forums.phpfreaks.com/topic/260453-having-problem-with-_get/ Share on other sites More sharing options...
scootstah Posted April 6, 2012 Share Posted April 6, 2012 Put quotes around the variable. WHERE video_id = '$super' LIMIT 1 Also, don't stick user input into your database like that or you will be vulnerable to SQL injection. I don't know what you're using to connect to the database so I can't offer any specifics. Link to comment https://forums.phpfreaks.com/topic/260453-having-problem-with-_get/#findComment-1334939 Share on other sites More sharing options...
AyKay47 Posted April 6, 2012 Share Posted April 6, 2012 Scootstah beat me to it here, but he's correct on one account. Since $super is passed from the query string, it is type string. So either cast it to an int or use intval() to sanitize the data. and be consistent with field qualifiers. $super = intval($_GET['video_id']); $filmai = $TSUE['TSUE_Database']->query("SELECT rasta_cinema.video_id, rasta_cinema.name, rasta_cinema.description, rasta_cinema.video_name, rasta_cinema.thumb_image FROM rasta_cinema WHERE rasta_cinema.video_id = $super LIMIT 1"); Link to comment https://forums.phpfreaks.com/topic/260453-having-problem-with-_get/#findComment-1334940 Share on other sites More sharing options...
scootstah Posted April 6, 2012 Share Posted April 6, 2012 So either cast it to an int or use intval() to sanitize the data. As long as the video_id field is an integer. Link to comment https://forums.phpfreaks.com/topic/260453-having-problem-with-_get/#findComment-1334941 Share on other sites More sharing options...
AyKay47 Posted April 6, 2012 Share Posted April 6, 2012 So either cast it to an int or use intval() to sanitize the data. As long as the video_id field is an integer. right, it has "id" in the name so one can only assume it's an int. Link to comment https://forums.phpfreaks.com/topic/260453-having-problem-with-_get/#findComment-1334942 Share on other sites More sharing options...
rastaman46 Posted April 6, 2012 Author Share Posted April 6, 2012 Thanks you save my day... Link to comment https://forums.phpfreaks.com/topic/260453-having-problem-with-_get/#findComment-1334975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.