joecooper Posted May 4, 2008 Share Posted May 4, 2008 Hi, used to be very skilled with php a while back but my brain has failed me! all i want to do is have $funds be the value of the funs field from the table users where the user is $username. help please. Link to comment https://forums.phpfreaks.com/topic/104102-mysql-help/ Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 Not much to go on there! $s = "SELECT * FROM users"; $res = mysql_query($s, $conn) or die(mysql_error()); $num_rows = mysql_num_rows($res); while ($a = mysql_fetch_array($res)) { $funds = $a['funds']; } or $s = "SELECT * FROM users"; $res = mysql_query($s, $conn) or die(mysql_error()); $num_rows = mysql_num_rows($res); if($num_rows==1) { $a = mysql_fetch_array($res) $funds = $a['funds']; } Link to comment https://forums.phpfreaks.com/topic/104102-mysql-help/#findComment-532950 Share on other sites More sharing options...
joecooper Posted May 4, 2008 Author Share Posted May 4, 2008 i have had some to drink so now is probally not the best time for me to try coding... but what you said i think is wrong... this is what im trying but not working $sql = "SELECT * FROM users WHERE username=$username"; $result = mysql_query($sql); $funds=$result['funds']; echo("Funds: $funds"); Link to comment https://forums.phpfreaks.com/topic/104102-mysql-help/#findComment-532961 Share on other sites More sharing options...
rarebit Posted May 4, 2008 Share Posted May 4, 2008 your missing the... $a = mysql_fetch_array($res) ...bit! Link to comment https://forums.phpfreaks.com/topic/104102-mysql-help/#findComment-532965 Share on other sites More sharing options...
joecooper Posted May 4, 2008 Author Share Posted May 4, 2008 ahhh i tried what you said exactly and it returned nothing im going out now. will come back to this stupid mysql thing tomorrow.. when sober Link to comment https://forums.phpfreaks.com/topic/104102-mysql-help/#findComment-532970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.