Jump to content

Archived

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

w0rdawg

Help with error.

Recommended Posts

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:
[code]
<?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` )
);
*/

?>[/code]

Can anyone help? Thanks.

Share this post


Link to post
Share on other sites
change
[code]
$query = mysql_query($querystring);
[/code]
to
[code]
$query = mysql_query($querystring) or die(mysql_error());
[/code]
and it will probably point you in the right direction (WHERE what = 1 ??)

Share this post


Link to post
Share on other sites
Probably the query you want is:
[code]$querystring = "SELECT name, email, post FROM shoutboxtut ORDER BY id DESC LIMIT 10";[/code]

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.