Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Browser window:
Connected to MySQL
Connected to Database

Notice: Undefined variable: link in C:\xampp\htdocs\globall\members.php on line 23

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\globall\members.php on line 23


this is line 23
$result = mysql_query($query,$link)

XML
<?php
mysql_connect("localhost", "admin", "") or die(mysql_error());

echo "Connected to MySQL<br />";

mysql_select_db("globall") or die(mysql_error());
echo "Connected to Database";

$query = " SELECT user_name,  mobile " .
        "FROM  customer ";


echo  "<br>" ;

$result = mysql_query($query,$link)
or die(mysql_error());

// this will count the total user in database
$num_users = mysql_num_rows($result);

$table_header =<<<EOD
<h2><center>GLoBALL Users Database </center></h2>

<table width="100%" border="1" cellpadding="2" cellspacing="2" align="center">
<tr>
<th>Username</th>
<th>Mobile</th>
</tr>

EOD;

$user_details = '';

while ($row = mysql_fetch_array($result)) {
$user_name = $row['user_name'];
$mobile = $row['mobile'];

$user_details .=<<<EOD
<tr>
<td>$user_name</td>
<td>$mobile</td>
</tr>
EOD;


$user_details .=<<<EOD
<tr>
<td>&nbsp;</td>
<td>Total : $num_users</td>
</tr>
EOD;
}
?>
Posted
Updated 17-Oct-18 8:34am
v2
Comments
Peta2010 21-Mar-12 8:59am    
I modify my whole code according to W3schools and facing error on this line :
Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\globall\members.php on line 32 which is
}
echo "</table>";



code start here-----


<tr>
<th>Username</th>
<th>Mobile</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row[$user_name]."</td>";
echo "<td>" . $row[$mobile]."</td>";
</tr>"
}
echo "</table>";

mysql_close($con);

?>

 
Share this answer
 
v2
Change the first line of code to
PHP
$link=mysql_connect("localhost", "admin", "") or die(mysql_error());


Thanks

Anand Ayyappan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900