Jump to content

[SOLVED] PHP Newbie needing a little help...


psyqosis

Recommended Posts

Hi. I think I'm missing something simple... any ideas?

 

I keep getting the error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in... on line 39

 

Here's the code in question (line 39 is the IF statement)

<?php

$database= "edited";

$db = mysql_connect(localhost, "edited", "edited");

mysql_select_db("$database", $db);

 

$sql = "SELECT * FROM events;";

$result = mysql_query($sql, $db);

if (mysql_num_rows($result) > 0) {

while ($myrow = mysql_fetch_array($result) ) {

?>

<TR><TD><?php echo $myrow['title']; ?></TD></TR>

<TR><TD><?php echo $myrow['date']; ?></TD></TR>

<TR><TD><?php echo $myrow['desc']; ?></TD></TR>

<?php

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/73271-solved-php-newbie-needing-a-little-help/
Share on other sites

LOLOLOLOL ;D

do this

$db = mysql_connect(localhost, "edited", "edited") or die(mysql_error());

mysql_select_db("$database", $db) or die(mysql_error());

 

$sql = "SELECT * FROM events;";

$result = mysql_query($sql, $db)or die(mysql_error());

 

 

we have to check if you are really connecting

Archived

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

×
×
  • Create New...

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.