pyp Code error

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Tue Oct 23, 2012 3:02 pm

Remove your mysql_close, that may fix it. additionally, this may be a slightly more readable way to do what you want...

Code: Select all

<?php 
$query="SELECT * from news";
$result=mysql_query($query);
echo "<B> News Table data</b> <br>";
$i=0;
while($row=mysql_fetch_assoc($result)) {
	$nheading = $row['nheading'];
	$ndetail = $row['ndetail'];
	$ntype= $row['ntype'];
	$ndate= $row['ndate'];
	$uploadeddate= $row['uploadeddate'];
	$i++;
}
echo "$i Rows listed.";
?>

tkdbb84
New php-forum User
New php-forum User
Posts: 137
Joined: Tue Mar 08, 2011 9:25 am

Tue Oct 23, 2012 7:15 pm

its because you have

Code: Select all


while($i < #num) {  
$nheading = mysql_result($result,$i,"nheading");
....
# is the deprecated comment for PHP, so the interpreter sees:

Code: Select all

while($i
$nheading = mysql_result($result,$i,"nheading");
hence an invalid semicolon.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests