php code not getting info from a MySQL database

Umbreon

Paragon
Joined
Jul 22, 2009
Messages
1,551
Reaction score
2
FP$
1,032
The problem is that the script is not picking up a certain from that ID. When I go to "domain.com/ViewGame?gid=34283", it doesn't pick up the gaming info from that ID in the mySQL.

Help anyone?

Code:
<?php
require('mysql.php');
mysql_select_db("ruko_fp", $con);

// Define the variables
$gid = $_GET['gid'];
$gametitle = $_GET['gametitle'];
$gamedescription = $_GET['gamedescription'];
$gamerating = $_GET['gamerating'];
$gamereview = $_GET['gamereview'];
$gameid = $_GET['gid'];
?>

TEST:

<h3><? $gametitle ?></h3>

Heres what is displayed on a certain ID:

TEST:

<game title supposed to be here>

Can someone rewrite the code for me please. If you do, I will rep ya.
 
Try this;

Code:
<?php

require_once(mysql.php);
mysql_select_db("ruko_fp", $con);

$result = mysql_query("SELECT * FROM table_name");
 while($row = mysql_fetch_array($result))
  {
   $gid = $row['gid'];
   $gametitle = $row['gametitle'];
   $gamedescription = $row['gamedescription'];
   $gamerating = $row['gamerating'];
   $gamereview = $row['gamereview'];
   $gameid = $row['gid'];
  }

?>

All you should have to do is replace table_name with the name of the table and it should work.
 
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/ruko/public_html/ViewGame.php on line 7

mysql.php
Code:
<?php
$con = mysql_connect("localhost","ruko_root","********);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
?>

And the url im at is ViewGame.php?gid=93823. The gid=93823 is a game id. If im in a certain ID, then it shows a certain game with that ID in the row.
 
So just so I understand, you want to get the game id from the url and then use that info to select a mysql row?
 
Alright, let's try this;

Code:
    <?php

    require_once(mysql.php);
    mysql_select_db("ruko_fp", $con);

    $thispage = $_SERVER["REQUEST_URI"];
    $game_id = strstr("$thispage","=");
    $game_id = substr($game_id, 1);

    $result = mysql_query("SELECT * FROM table_name WHERE gid='$game_id'");
    $num_rows = mysql_num_rows($result);
    if($num_rows == 0)
     {
       echo "We could not find that game, sorry.";
     }
    else
     {
       while($row = mysql_fetch_array($result))
        {
         $gametitle = $row['gametitle'];
         $gamedescription = $row['gamedescription'];
         $gamerating = $row['gamerating'];
         $gamereview = $row['gamereview'];
        }
      }

    ?>

That one should work, you'll just have to change table_name to the right name.
 
Ah, glad to hear. All these late nights with php are starting to pay off :great:
 
Back
Top Bottom