Jump to content

Archived

This topic is now archived and is closed to further replies.

pro_se

help with query

Recommended Posts

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 45

I have no idea what is wrong... maybe someone can help me?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
nope... same error... Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/user.php on line 53  ???

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
id  to    from          ip                    msg                                  date        time
1 corey Nil Thacker 10.160.43.200 Testing the comment system... July 28, 2006 1:03

in a table called comments...

my address bar looks like: http://localhost/users.php?name=corey

Share this post


Link to post
Share on other sites
no sessions... my address bar looks like: http://localhost/users.php?name=corey

its a comment system where anyone can comment

Share this post


Link to post
Share on other sites
add ip=ip in the link ok

post 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]

Share this post


Link to post
Share on other sites
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 56

address bar: user.php?name=corey&ip=10.160.43.200

Share this post


Link to post
Share on other sites
add all the table in link and get ok

madness but might work some reason not working strange got me lol..................

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
ive got it haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

your date is wrong should be 01-01-06

the format i mean ok.

hahaha


$date=date("d-m-y");
$time=date("h:i:s");

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

×

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.