Jump to content


Photo

A Little Help...Displaying


  • Please log in to reply
3 replies to this topic

#1 cryp7

cryp7
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 25 March 2006 - 05:13 PM

Ive Done A Search and cant find ne thing that helps me

i got...

<?php
mysql_connect("localhost", "xxx", "xxx") or
die("Could not connect: " . mysql_error());
mysql_select_db("xxx");


$img_skin = "SELECT img_skin FROM character WHERE username='admin'";
$img_skin_res = mysql_query($img_skin);

$name = "SELECT name FROM character WHERE username='admin'";
$name_res = mysql_query($name);

$row_img=mysql_fetch_array($img_skin_res);
$img_skin_string = $row_img['img_skin'];

$row_name=mysql_fetch_array($name_res);
$name_string = $row_name['name'];

echo "IMG: $img_skin_string, Name: $name_string";

mysql_free_result($img_skin_string);
mysql_free_result($name_string);
?>

What i want is the results "img_skin" and "name" for admin, which are stored in the "character" table, to be printed...ive tried searching and doing everything that i can think of now im stuck :S

And This is what i get

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 103

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 106
IMG: , Name:
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 111

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 112

so help would be loved - thxs

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 25 March 2006 - 06:05 PM

Try this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
mysql_connect("localhost", "xxx", "xxx") or
die("Could not connect: " . mysql_error());
mysql_select_db("xxx");


$img_skin = "SELECT img_skin,name FROM character WHERE username='admin'";
$img_skin_res = mysql_query($img_skin) OR die(mysql_error());

$row_img=mysql_fetch_array($img_skin_res);
$img_skin_string= $row_img['img_skin'];
$name_string = $row_img['name'];

echo "IMG: $img_skin_string, Name: $name_string";

mysql_free_result($img_skin_res);

?>[/quote]

If it still doesn't work then you will get an error for the SQL statement which will tell you where in the wuery the error is.

Regards
Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 cryp7

cryp7
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 25 March 2006 - 06:12 PM

thxs for the reply - your right it didn't work but i told me something new...

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'character WHERE username='admin'' at line 1
[/quote]

this doesn't actually mean anything to me :S soz

thxs again

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 March 2006 - 04:31 PM

The word "character" is probably a reserved word in MySQL, surround it with back ticks (`):
<?php
$img_skin = "SELECT img_skin,name FROM `character` WHERE username='admin'";
$img_skin_res = mysql_query($img_skin) OR die('Problem with query:' . $img_skin . '<br>' . mysql_error());
?>
I always print out the query that caused the problem in the "or die" clause.

Ken





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users