Jump to content

Archived

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

DarthViper3k

not valid SQL?

Recommended Posts

ok

 

I\'ve spent the better part of.... all day coding some PHP pages for my project (Private Messaging System.. Inbox and Send Private Message..... each are bout 150 or 200+ lines of code)

 

brain... fried....

need extra pair of eyes to debug

 

error

Warning: Supplied argument is not a valid MySQL result resource in c:apachehtdocs3kphpInbox.php on line 40

 

block of code with error

[php:1:decfc04bb6]

while($pmnum = mysql_fetch_array($result)){ //line 40

if(mysql_num_rows($result) == 0) {

echo(\"You don\'t have any Messages\");

} else {

print(\"<TR><TD WIDTH=\'25%\'>\");

echo $pmnum[from];

print(\"</TD> <TD WIDTH=\'50%\'>\");

echo $pmnum[subject];

print(\"</TD> <TD WIDTH=\'25%\'>\");

echo $pmnum[sent];

print(\"</td></TR>\");

}

}

[/php:1:decfc04bb6]

Share this post


Link to post
Share on other sites

your query ( not listed ) didn\'t return any results... :shock: does it work if you ad hoc it? any syntax errors?

Share this post


Link to post
Share on other sites
your query ( not listed ) didn\'t return any results...  :shock: does it work if you ad hoc it? any syntax errors?

 

thats the only error I got....

 

didn\'t think about adding some rows to the database to see if it actually works

 

I\'m gonna try that

 

that is what your sayin right?

 

edit...

now I got that same error on line 15 as well as the above posted error

 

[php:1:fd6390f548]

$limit = 15;

$messages = \"SELECT users FROM messages WHERE to=\'$username\'\";

$getmessages = mysql_query($messages);

$pmnum = mysql_num_rows($getmessages); //line 15

[/php:1:fd6390f548]

Share this post


Link to post
Share on other sites

I guess the problem is either with ur connection string or ur query

 

Try to run the query seperately and see whether u get any values.

 

$link = mysql_connect(\"localhost\", \"username\", \"password\");

mysql_select_db(\"database\", $link);

 

 


mysql_query($messages) or die("problem here ");

Share this post


Link to post
Share on other sites

uhh

 

ok

this makes no sense

 

I got a 500 Internal Server Error

 

I have no idea whats goin on

 

edit: nevermind

the error is gone

however...

my old error remains

 

ok

this makes a lot of sense

I remove the or die(); part and it works fine

 

edit

ok

I added more of the code and I have that same error

 

Warning: Supplied argument is not a valid MySQL result resource in c:apachehtdocsmysqlqtest.php on line 7

 

[php:1:ac080681c1]

$messages = \"SELECT users FROM messages\";

$getmessages = mysql_query($messages);

$pmnum = mysql_num_rows($getmessages); // line 7

[/php:1:ac080681c1]

 

what exactly is goin on?

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.