Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/15865-help-with-query/
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]
Link to comment
https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65051
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]
Link to comment
https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65053
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
Link to comment
https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65057
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]
Link to comment
https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65061
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]
Link to comment
https://forums.phpfreaks.com/topic/15865-help-with-query/#findComment-65065
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.