Jump to content

Recommended Posts

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

i got...

[code]
<?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);
?>
[/code]

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

[code]
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
[/code]

so help would be loved - thxs
Link to comment
https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/#findComment-20629
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/#findComment-20634
Share on other sites

The word "character" is probably a reserved word in MySQL, surround it with back ticks (`):
[code]<?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());
?>[/code]
I always print out the query that caused the problem in the "or die" clause.

Ken
Link to comment
https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/#findComment-20865
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.