0

Sorry very very new to php , obviously my code below is wrong. What should the code be?

$result = mysql_query("SELECT * FROM TEST Where Name LIKE 'Smith%'") 
or die(mysql_error()); 

// Print out result
while($row = mysql_fetch_array($result)){
	echo "There are ". $row['COUNT(Surname)'] .";
}

Thanks If anyone can help

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by edwinhermann
0
$result = mysql_query("SELECT COUNT(*) FROM TEST Where Name LIKE 'Smith%'") or die(mysql_error()); 

// Print out result
while($row = mysql_fetch_array($result)){
	echo "There are ". $row[0] .";
}
0

thanks for the help, but i get an error on the page row number that is outside the </body> of the page????

What is the problem please?

0

PHP Syntax (Toggle Plain Text)

$result = mysql_query("SELECT COUNT(*) FROM TEST Where Name LIKE 'Smith%'") or die(mysql_error()); 

// Print out result
while($row = mysql_fetch_array($result)){
    echo "There are ". $row['COUNT(Surname)'] ."; <-- This is the problem I guess
}

There should be another double quote right.

Edited by Reverend Jim: Fixed formatting

0

Oh yeah, I forgot :) WickedSelf is right.

Alternatively, you can take out the dot-double-quote, so you're left with this:

$result = mysql_query("SELECT COUNT(*) FROM TEST Where Name LIKE 'Smith%'") or die(mysql_error()); 

// Print out result
while($row = mysql_fetch_array($result)){
	echo "There are ". $row[0];
}

Edited by edwinhermann: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.