Jump to content

I'm making an experimental php mailing list


webdesignmad

Recommended Posts

I'm making a php mailing list where users submit their name and email. It adds that to a database. But when i try to open viewSubscribers.php (the file displaying users), it says "Warning: mysql_num_rows() expects parameter 1 to be resource, string given in M:\Programs\xampp\htdocs\HTML\ViewSubscribers.php on line 22". Here's the code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

<title>ViewSubscribers.php</title>

</head>

<body>

<table>

<tr>

<th align="left">Name</th>

<th align="left">Email</th>

</tr>

</table>

<table>

<?php

$link = mysql_connect("localhost", "my_username", "my_password") or die ('I cannot connect to the DB');

mysql_select_db ("mailinglist",$link) or die ("Unable to select DB.");

$query="SELECT * FROM mailinglist";

$result=mysql_query($query, $link);

$num=mysql_num_rows("$result");

mysql_close();

$i=0;

while ($i < num){

$name=mysql_result($result,$i,"name");

$email=mysql_result($result,$i,"email");

?>

<tr>

<td>

<?php

print $name

?>

</td>

<td>

<?php

print

$email ?>

</td>

</tr>

<?php

$i++;

}

?>

</table>

</body>

</html>

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.