pro_se Posted July 28, 2006 Share Posted July 28, 2006 I have a query that is looking up a users comments:[code]<?php $uname = $_GET['name'];$result = mysql_query("select * from comments where to=$uname");while($r = mysql_fetch_array($result)){ $from=$r["from"]; $msg=$r["msg"]; $time=$r["time"]; $date=$r["date"]; echo "$msg<br /> <sub>$from | $date | $time</sub> <hr color=#B0B0B0 noshade=noshade size=1/>";}?>[/code]and I keep getting an error like this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/user.php on line 45I have no idea what is wrong... maybe someone can help me? Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/ Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 try this ok.[code]<?php$uname = $_GET['name'];$query="select * from comments where to='$uname'";$result=mysql_query($query);while($r = mysql_fetch_assoc($result)) { $from=$r["from"]; $msg=$r["msg"]; $time=$r["time"]; $date=$r["date"]; echo "$msg<br /> <sub>$from | $date | $time</sub> <hr color=#B0B0B0 noshade=noshade size=1/>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65051 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 nope... same error... Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/user.php on line 53 ??? Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65052 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 post your findings ok.[code]<?php$uname = $_GET['name'];$query="select * from comments where uname='$uname'";print_r($query);$result=mysql_query($query);while($r = mysql_fetch_assoc($result)) { $from=$r["from"]; $msg=$r["msg"]; $time=$r["time"]; $date=$r["date"]; echo "$msg<br /> <sub>$from | $date | $time</sub> <hr color=#B0B0B0 noshade=noshade size=1/>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65053 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 select * from comments where uname='corey'Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/user.php on line 56 Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65054 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 that is the right query... this is weird... Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65055 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 what the table info please as i see no id Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65056 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 id to from ip msg date time1 corey Nil Thacker 10.160.43.200 Testing the comment system... July 28, 2006 1:03in a table called comments...my address bar looks like: http://localhost/users.php?name=corey Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65057 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 also show me the link to get to this page ok. Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65058 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 are you using sessions Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65059 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 no sessions... my address bar looks like: http://localhost/users.php?name=corey its a comment system where anyone can comment Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65060 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 add ip=ip in the link okpost the findings[code]<?php$ip = $_GET['ip'];$uname = $_GET['name'];$query="select * from comments where uname='$uname' and ip='$ip'";print_r($query);$result=mysql_query($query);while($r = mysql_fetch_assoc($result)) { $from=$r["from"]; $msg=$r["msg"]; $time=$r["time"]; $date=$r["date"]; echo "$msg<br /> <sub>$from | $date | $time</sub> <hr color=#B0B0B0 noshade=noshade size=1/>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65061 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 select * from comments where uname='corey' and ip='10.160.43.200'Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/user.php on line 56address bar: user.php?name=corey&ip=10.160.43.200 Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65062 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 add all the table in link and get okmadness but might work some reason not working strange got me lol.................. Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65063 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 ahhh!!!!! it still does not work!!!!!!!! same error... wow... link: user.php?name=corey&ip=10.160.43.200&time=1:03&date=July%2028,%202006 Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65064 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 try this for a min ok see if we can get somthink out lol ...........[code]<?php$uname = $_GET['name'];$query="select * from comments where uname='$uname''";print_r($query);$result=mysql_query($query);while(list($key,$val)=each($result)) { echo "$key : $val ";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65065 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 ive got it haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaayour date is wrong should be 01-01-06the format i mean ok.hahaha $date=date("d-m-y");$time=date("h:i:s"); Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65067 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 dude... it was not that... i got it.... it was the name thing... for the $_GET.... i had it named wrong.... wow... im am a dummy... Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65068 Share on other sites More sharing options...
pro_se Posted July 28, 2006 Author Share Posted July 28, 2006 thanks for all ur help! :P Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65069 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 ok mate good luck all the best Quote Link to comment https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65070 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.