ohdang888 Posted December 31, 2007 Share Posted December 31, 2007 hey, my code is below. it would be located in a url called "game.php?title=GAMETITLE" <?php $game = @$_GET['title'] ; mysql_connect("localhost", "----, "------") or die(mysql_error()); mysql_select_db("games") or die(mysql_error()); $result = mysql_query("SELECT title FROM game WHERE game='$game'") or die(mysql_error()); echo $result; ?> but if the next thing i want to do is query the name of the author of that specific game.... 1. would it grab it the author info from the same row as the game if my code is... <?php $game = @$_GET['title'] ; mysql_connect("localhost", "---", "---" or die(mysql_error()); mysql_select_db("games") or die(mysql_error()); $result = mysql_query("SELECT author FROM game WHERE game='$game'") or die(mysql_error()); echo $result; ?> ?????????????????????????????????? Quote Link to comment https://forums.phpfreaks.com/topic/83794-another-mysql-question/ Share on other sites More sharing options...
PHP_PhREEEk Posted December 31, 2007 Share Posted December 31, 2007 <?php $game = @$_GET['title'] ; mysql_connect("localhost", "----", "------") or die(mysql_error()); mysql_select_db("games") or die(mysql_error()); if ( !$result = mysql_query("SELECT `title`, `author` FROM `game` WHERE `game`='$game' LIMIT 0,1") ) { die('MySQL Error: ' . mysql_error()); } list($title, $author) = mysql_fetch_assoc($result); echo $title . '<br>'; echo $author; ?> PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/83794-another-mysql-question/#findComment-426359 Share on other sites More sharing options...
ohdang888 Posted December 31, 2007 Author Share Posted December 31, 2007 ok so i used that code. there are no errors, (i put "echo 'end of script'" and it showed up) and i have info my database and put the name of the game in the url and it didn;t work Quote Link to comment https://forums.phpfreaks.com/topic/83794-another-mysql-question/#findComment-426364 Share on other sites More sharing options...
PHP_PhREEEk Posted December 31, 2007 Share Posted December 31, 2007 Then let's put the query into a variable and echo it to see what we're actually asking MySQL... <?php $game = @$_GET['title'] ; mysql_connect("localhost", "----", "------") or die(mysql_error()); mysql_select_db("games") or die(mysql_error()); $sql = "SELECT `title`, `author` FROM `game` WHERE `game`='$game' LIMIT 0,1 "; if ( !$result = mysql_query($sql) ) { die('MySQL Error: ' . mysql_error()); } die('SQL:<br>' . $sql); list($title, $author) = mysql_fetch_assoc($result); echo $title . '<br>'; echo $author; ?> PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/83794-another-mysql-question/#findComment-426388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.