Jump to content

[SOLVED] [help] PHP DATABASE HELP


Tagette

Recommended Posts

<?php

 

//The purpose of this is to build an xml document so I can relay the information to a flash file

 

error_reporting(0); //Stops errors from poping up and messing up flash

 

$char = $_GET['char']; //uses GET method to access name from previous page

$error = 0;

 

$con = mysql_connect("host","user","pass");

if (!$con) {

$error++;

}

$db = mysql_select_db("db_name");

if (!$db) {

$error++;

}

echo "<?xml version=\"1.0\"?>\n"; //Makes it an official xml file

echo "<character>\n"; //Open tag for character information

 

//Problem is that when I go to the page, the php file does not get information from the database like it should.

//I did have correct connection information, but for for obvious reasons I removed them. So thats not the problem.

 

$query = 'SELECT * FROM characters WHERE name="'.$char.'"'; //I expect only one outcome from this query

$results = mysql_query($query);

$row = mysql_fetch_assoc($results); // I've tried both mysql_fetch_assoc and mysql_fetch_array here. Niether work.

 

$name = $row['name'];   //These return no value \/

$gender = $row['gender'];

$job = $row['job'];

$level = $row['level'];

$hp = $row['maxhp'];

$mp = $row['maxmp'];

$exp = $row['exp'];

$fame = $row['fame'];

$str = $row['str'];

$dex = $row['dex'];

$int = $row['int'];

$luk = $row['luk'];

$money = $row['money'];

$guildid = $row['guildid'];   //These return no value /\

 

 

$query2 = 'SELECT * FROM guilds WHERE guildid="'.$guildid.'"'; //I expect only one outcome from this query also

$results2 = mysql_query($query2);

$row2 = mysql_fetch_assoc($results2); // I've also tried both mysql_fetch_assoc and mysql_fetch_array here niether work

 

$guildname = $row2['name'];

 

if($error==0){

echo "\t<info>1</info>\n";

echo "\t<info>".$name."</info>\n";   //The php variables dont hold any values for some reason \/

echo "\t<info>".$gender."</info>\n";

echo "\t<info>".$job."</info>\n";

echo "\t<info>".$level."</info>\n";

echo "\t<info>".$hp."</info>\n";

echo "\t<info>".$mp."</info>\n";

echo "\t<info>".$exp."</info>\n";

echo "\t<info>".$fame."</info>\n";

echo "\t<info>".$str."</info>\n";

echo "\t<info>".$dex."</info>\n";

echo "\t<info>".$int."</info>\n";

echo "\t<info>".$luk."</info>\n";

echo "\t<info>".$money."</info>\n";

echo "\t<info>".$guildname."</info>\n";   //The php variables dont hold any values for some reason /\

}else{

echo "<info>0</info>\n";

echo "<info>Cannot connect.</info>\n";

}

 

echo "</character>\n"; //Closing tag for character information

 

mysql_close($con);

?>

 

Whats happening:

 

<?xml version="1.0"?>

<character>

<info>1</info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

<info></info>

</character>

 

What should happen:

 

<?xml version="1.0"?>

<character>

<info>1</info>

<info>Scarlet</info> //name

<info>0</info>  //gender

<info>522</info> //job

<info>255</info> //level

<info>30000</info> //hp

<info>30000</info> //mp

<info>26455161518</info> //exp

<info>1337</info> //fame

<info>32767</info> //str

<info>32767</info> //dex

<info>32767</info> //int

<info>32767</info> //luk

<info>2000000000</info> //money

<info>BossGuild</info> //guildname

</character>

 

Can someone help please I'm new at php. Thanks a lot.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.