cryp7 Posted March 25, 2006 Share Posted March 25, 2006 Ive Done A Search and cant find ne thing that helps mei got...[code]<?phpmysql_connect("localhost", "xxx", "xxx") ordie("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 :SAnd 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 103Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 106IMG: , Name:Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/andy/public_html/character.php on line 111Warning: 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 Quote Link to comment https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/ Share on other sites More sharing options...
shocker-z Posted March 25, 2006 Share Posted March 25, 2006 Try this:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?phpmysql_connect("localhost", "xxx", "xxx") ordie("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.RegardsLiam Quote Link to comment https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/#findComment-20629 Share on other sites More sharing options...
cryp7 Posted March 25, 2006 Author Share Posted March 25, 2006 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 sozthxs again Quote Link to comment https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/#findComment-20634 Share on other sites More sharing options...
kenrbnsn Posted March 26, 2006 Share Posted March 26, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/5783-a-little-helpdisplaying/#findComment-20865 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.