jamesxg1 Posted January 17, 2010 Share Posted January 17, 2010 Hiya, I am getting this. Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\Program Files\xampp\htdocs\aff\register.php on line 119 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\Program Files\xampp\htdocs\aff\register.php on line 126 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\Program Files\xampp\htdocs\aff\register.php on line 160 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\Program Files\xampp\htdocs\aff\register.php on line 166 Here's the code I am using. if(ereg("^[^@]{1,64}@[^@]{1,255}$", $levelone)): $this->levelOneUser = mysql_real_escape_string(trim($levelone)); else: return 'Registration Failed!'; endif; $this->levelOneSelectEarnings = "SELECT `earnings` FROM `members` WHERE emailaddress = '$this->levelOneUser' LIMIT 1"; $this->levelOneInsert = "UPDATE `members` SET earnings = '$this->levelOneTotal' WHERE emailaddress = '$this->levelOneUser' LIMIT 1"; $this->levelOneSelectReferral = "SELECT `referrer` FROM `referrals` WHERE member = '$this->levelOneUser' LIMIT 1"; if(mysql_query($this->levelOneSelectEarnings) == TRUE): while($this->earnings = mysql_fetch_assoc($this->levelOneSelectEarnings)): $this->levelOneTotal = $this->earnings['earnings'] + 1.00; endwhile; if(mysql_query($this->levelOneSelectReferral) == TRUE): while($this->referrer = mysql_fetch_assoc($this->levelOneSelectReferral)): $this->referrer = $this->referrer['referrer']; endwhile; if(mysql_query($this->levelOneInsert)): $this->leveltwo($this->referrer); else: return 'Registeration failed!'; endif; else: return 'Registeration failed!'; endif; else: return 'Registeration failed!'; endif; } This is part of my class. line 119 is while($this->earnings = mysql_fetch_assoc($this->levelOneSelectEarnings)): Many thanks James. Link to comment https://forums.phpfreaks.com/topic/188782-fetching-error-and-while-error/ Share on other sites More sharing options...
jamesxg1 Posted January 17, 2010 Author Share Posted January 17, 2010 Slight code update. Still get the error's. function levelOne($levelone) { if(ereg("^[^@]{1,64}@[^@]{1,255}$", $levelone)): $this->levelOneUser = mysql_real_escape_string(trim($levelone)); else: return 'Registration Failed!'; endif; $this->levelOneSelectEarnings = "SELECT `earnings` FROM `members` WHERE emailaddress = '$this->levelOneUser' LIMIT 1"; $this->levelOneInsert = "UPDATE `members` SET earnings = '$this->levelOneTotal' WHERE emailaddress = '$this->levelOneUser' LIMIT 1"; $this->levelOneSelectReferral = "SELECT `referrer` FROM `referrals` WHERE member = '$this->levelOneUser' LIMIT 1"; if(mysql_query($this->levelOneSelectEarnings) == FALSE): return 'Registeration failed!' . mysql_error(); else: while($this->earnings = mysql_fetch_assoc($this->levelOneSelectEarnings)): $this->levelOneTotal = $this->earnings['earnings'] + 1.00; endwhile; if(mysql_query($this->levelOneSelectReferral) == FALSE): return 'Registeration failed!' . mysql_error(); else: while($this->referrer = mysql_fetch_assoc($this->levelOneSelectReferral)): $this->referrer = $this->referrer['referrer']; endwhile; if(mysql_query($this->levelOneInsert) == FALSE): return 'Registeration failed!' . mysql_error(); else: $this->leveltwo($this->referrer); endif; endif; endif; } Many thanks James. Link to comment https://forums.phpfreaks.com/topic/188782-fetching-error-and-while-error/#findComment-996665 Share on other sites More sharing options...
Buddski Posted January 17, 2010 Share Posted January 17, 2010 You are passing in the actual SQL string not the resource created via mysql_query() Link to comment https://forums.phpfreaks.com/topic/188782-fetching-error-and-while-error/#findComment-996666 Share on other sites More sharing options...
jamesxg1 Posted January 17, 2010 Author Share Posted January 17, 2010 Christ hell's bell's!, damn! lol. Thanks mate. Many thanks James. Link to comment https://forums.phpfreaks.com/topic/188782-fetching-error-and-while-error/#findComment-996669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.