Jump to content


Photo

Help with error.


  • Please log in to reply
2 replies to this topic

#1 w0rdawg

w0rdawg
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 07 May 2006 - 08:20 PM

I don't know what I am doing wrong, but I'm get a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/place/public_html/view_shout.php on line 9"

Here's the code the error is coming from:
<?php

include( "mysql_info.php" );
include( "mysql_connect.php" );

$querystring = "SELECT name, email, post FROM shoutboxtut WHERE 1 ORDER BY id DESC LIMIT 10";
$query = mysql_query( $querystring );

while( $a = mysql_fetch_array( $query, MYSQL_ASSOC ) ) {
    if( !empty( $a['email'] ) ) {
        $email_start = "<a href=\"mailto:".$a['email']."\" style=\"font-weight:bold;\">";
        $email_end = "</a>";
    } else {
        $email_start = "";
        $email_end = "";
    };
    
    print "Posted by ".$email_start.$a['name'].$email_end.":<br>";
    print stripslashes( $a['post'] )."<BR><HR>";
};

// table create code:
/* CREATE TABLE `shoutboxtut` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`ipa` VARCHAR( 15 ) NOT NULL ,
`name` VARCHAR( 255 ) NOT NULL ,
`email` VARCHAR( 255 ) ,
`post` TEXT NOT NULL ,
PRIMARY KEY ( `id` )
);
*/

?>

Can anyone help? Thanks.

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 07 May 2006 - 09:03 PM

change
$query = mysql_query($querystring);
to
$query = mysql_query($querystring) or die(mysql_error());
and it will probably point you in the right direction (WHERE what = 1 ??)

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 07 May 2006 - 09:43 PM

Probably the query you want is:
$querystring = "SELECT name, email, post FROM shoutboxtut ORDER BY id DESC LIMIT 10";

Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users