Jump to content


Photo

not valid SQL?


  • Please log in to reply
4 replies to this topic

#1 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 12 March 2003 - 06:03 AM

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]
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 12 March 2003 - 06:52 AM

your query ( not listed ) didn\'t return any results... :shock: does it work if you ad hoc it? any syntax errors?
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 12 March 2003 - 02:25 PM

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]
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#4 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 17 March 2003 - 10:32 PM

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

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#5 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 18 March 2003 - 12:39 AM

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?
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users