tags:

views:

114

answers:

3

I have a huge table to put in the while loop, but i'm finding it difficult to concatenate it. How can I add multilines with more ?

<?php
$dbhost = 'xxxx';
$dbuser = 'xxxx';
$dbpass = 'xxxx';
$dbname = 'xxxx';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname, $conn);

$result = mysql_query("SELECT * FROM table", $conn);

while ($row = mysql_fetch_array($result)) 
{
    echo '<tr align="center"><td width='200'>' . htmlspecialchars($row['Picturedata']) . '</td>';
    echo '<td width="700"><h1>' . htmlspecialchars($row['name'] . '</td>' ;    
}

?>

I get syntax error, unexpected ';'

+1  A: 

Update: You are missing a ')' on your second echo in the while loop.

The code you posted looks entirely valid to me. Maybe there is an issue or missing semicolon elsewhere in your file?

Scott S.
I agree the problem is probably further up in the code, and it's probably a missing ' or "
Unkwntech
No, it says that there is an unexpected ';' in the second echo line :/
Joe
@Joe Post the entire file so we can take a look.
Scott S.
Posted the code
Joe
ooooops..Thanks for your help
Joe
+4  A: 

In the posted code this line is missing a closing parentheses after ['name']:

echo "<td width='700'><h1>" . htmlspecialchars($row['name'] . "</td>" ;

It should be

echo "<td width='700'><h1>" . htmlspecialchars($row['name']) . "</td>" ;
Amber
ooops!thanks for helping
Joe
A: 

Note that echo doesn't actually add a new line to the output. If you want a new line in the HTML output (though it won't be visible in the browser due to the way HTML treats new lines) then you either do something like

echo '<td> blah </td>
<td> blah </td>
';

or you can use \n in a double-quoted string:

echo "<td> blah </td>\n<td> blah </td>\n";

or

echo "<td> blah </td>\n";
echo "<td> blah </td>\n";
Artelius