how to make games.php?id=

Hey guys. I am building a games website, and I am using ID (example: games.php?id_) to view games with their Title, SWF file to play, and their Image Icon. I am basically fetching information per game using ID that is typed in the URL after my website address containing the ‘?id_’ or ‘?id=’. Can somebody tell me whats wrong with the code I have bellow, because it’s not working. I always get parse error (T_STRING) at line 9.

This code is inside my games.php page. It doesn’t seem to work.


<?php $conn = mysql_connect("host", "username", "password"); mysql_select_db("games"); $game_id = $_GET['id']; $sql = "SELECT * FROM games WHERE id='$game_id' LIMIT 1"; $result = mysql_query($sql, $conn) or die(mysql_error()); $number_of_results = mysql_num_rows($result); while ($result_array = mysql_fetch_array($result, MYSQL_ASSOC)) { $id = $result_array['fldID']; $title = $result_array['fldTitle']; $graphic = $result_array['fldIconSmall']; // Example: game1234.png $swf = $result_array['fldSwfSrc']; // Example: game1234.swf $graphic_file_location = '' . $graphic; $swf_file_location = '' .$swf; echo ''; echo '

' . $title . '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } ?>


Any help would be appreciated since so far this script has not executed at all. I keep getting an error when executing this entire script. I can’t find any errors in it either…but it just doesn’t work.

remove the quotes here: WHERE id=$game_id LIMIT 1 :as id is an integer you don’t need the quotes…

Sponsor our Newsletter | Privacy Policy | Terms of Service