Jump to content

Archived

This topic is now archived and is closed to further replies.

Tkaspers88

PHP/Database.. White Page (Cant find my error)

Recommended Posts

Greetings,

I have a website about an online game.. the game has 130 creatures and I made a database for the creatures.. that stores all the information about them..

I have a file called creature.php that should read all the information from the database and it should show it with an url like this: www.mysite.com/creature.php?xd=amazon



Im using the following code:

[code]<?php
$host = 'localhost';
$username = 'xxxxxxxxx';
$password = 'xxxxxxxxx';
$db = 'xxxxxxxxx';

$server = mysql_connect($host, $username, $password);

mysql_select_db($db);

$sql = "SELECT * FROM Creatures WHERE NameUrl = '".$_GET['xd']."'";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result) > 0)
{
    while($row = mysql_fetch_assoc($result))
    {
        $ImageAdress = $row['ImageAdress'];
        $Name = $row['Name'];
$Description = $row['Description'];
$Experience = $row['Experience'];
$Hitpoints = $row['Hitpoints'];
$Summon = $row['Summon'];
$Convince = $row['Convince'];
$Attacks = $row['Attacks'];
$Immunities = $row['Immunities'];
$Specials = $row['Specials'];
$Loot = $row['Loot'];
$Yell = $row['Yell'];
$XDComment = $row['XDComment'];
$ScreenAdress $row['ScreenAdress'];
    }
}
else
{
      header('Location: http://www.tibiaxd.net/preview/items/creaturesoverview.php');
}
?>[/code]

NameUrl is the name of the creature without capitals or spaces.. (amazon here)
My table is called Creatures

This is an example of my database:
[img]http://img145.imageshack.us/img145/4430/databasebi3.jpg[/img]


Im getting the information on its place by adding :  <?php echo ("$Name"); ?>  etc..

I think this all is correct.. but still, when I go to www.mysite.com/creature.php?xd=amazon, all I see is a white page.. >.<'


Someone see's the error? I cant find it..

Thanks in advance,
Tkaspers~

Share this post


Link to post
Share on other sites
<?php session_start();

if($_GET['id']=="amazon") {

$host = 'localhost';
$username = 'xxxxxxxxx';
$password = 'xxxxxxxxx';
$db = 'xxxxxxxxx';

$server = mysql_connect($host, $username, $password);

mysql_select_db($db);

$sql = "SELECT * FROM Creatures WHERE NameUrl = '".$_GET['xd']."'";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result) > 0)
{
     while($row = mysql_fetch_assoc($result))
     {
         $ImageAdress = $row['ImageAdress'];
         $Name = $row['Name'];
$Description = $row['Description'];
$Experience = $row['Experience'];
$Hitpoints = $row['Hitpoints'];
$Summon = $row['Summon'];
$Convince = $row['Convince'];
$Attacks = $row['Attacks'];
$Immunities = $row['Immunities'];
$Specials = $row['Specials'];
$Loot = $row['Loot'];
$Yell = $row['Yell'];
$XDComment = $row['XDComment'];
$ScreenAdress = $row['ScreenAdress'];
     }
}
else
{
       header('Location: http://www.tibiaxd.net/preview/items/creaturesoverview.php');
}
}else{

echo"sorry no result";
}
?>

Share this post


Link to post
Share on other sites
Ah.. thanks redarrow :)

It works now.. I changed my    <?php    into    <?php session_start();
and it works :).. Thanks

Greetings,
Tkaspers

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.