Jump to content


Photo

help with query


  • Please log in to reply
19 replies to this topic

#1 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 08:16 AM

I have a query that is looking up a users comments:
<?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/>";
}
?>

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?

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 08:47 AM

try this ok.
<?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/>";
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 08:52 AM

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

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 08:54 AM

post your findings ok.
<?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/>";
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 08:57 AM

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

#6 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 08:58 AM

that is the right query... this is weird...

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:01 AM

what the table info please as i see no id

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 09:02 AM

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

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:03 AM

also show me the link to get to this page ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:04 AM

are you using sessions
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 09:05 AM

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

its a comment system where anyone can comment

#12 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:07 AM

add ip=ip in the link ok

post the findings

<?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/>";
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#13 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 09:11 AM

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

#14 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:13 AM

add all the table in link and get ok

madness but might work some reason not working strange got me lol..................
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#15 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 09:15 AM

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

#16 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:16 AM

try this for a min ok see if we can get somthink out lol ...........
<?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 ";

}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#17 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:21 AM

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");


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#18 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 09:25 AM

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...

#19 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 28 July 2006 - 09:26 AM

thanks for all ur help! :P

#20 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 July 2006 - 09:26 AM

ok mate good luck all the best
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users