![]() |
php question
I am new to php and am working on a script to show search results. I am getting the following error with this and was wondering if I am doing something wrong or have the wrong version of php on my server because I am copying this code directly from php5 and mysql4 for dummies and have php4 on my server:
<?php $user = "user"; $host = "localhost"; $password = "pass"; $database = "database"; $connection = mysql_connect($host,$user,$password) or die ("Couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); $query = "SELECT * FROM `features`"; $result = mysql_query($query) or die ("Couldn't execute query."); /* Dsiplay results in a table */ echo "<table cellspacing='10' border=0' cellpadding='0' width='100%'?"; echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n; while ($row = mysql_fetch_array{result,MYSQL_ASSOC)) { /* display row for each listingid */ echo "<tr>\n; echo "<td>{$row['intersection1']}</td>\n"; ?> I get his error: Parse error: parse error, unexpected '>' in /public_html/pa/index.php on line 26 |
you need a " at the end of your echo
|
twice
... |
change this:
echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n; to: echo "<tr><td colspan='5' align='right'>Click on any picture to see a larger version.<br><hr></td></tr>\n"; in case it wasn't obvious what arnette said... |
Quote:
echo "<tr>\n; to: echo "<tr>\n"; |
No you didn't close the loop with a }
|
Also, this is better written from,
Code:
echo "<td>{$row['intersection1']}</td>\n"; Code:
echo "<td>".$row['intersection1']."</td>\n"; |
Quote:
|
Still shows same error after changing to:
/* display row for each listingid */ echo "<tr>\n"; echo "<td>{$row['intersection1']}</td>\n"; ?> |
Quote:
put a } before the ?> |
also
while ($row = mysql_fetch_array{result,MYSQL_ASSOC)) is wrong, it should be while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) |
Ok changed to:
Code:
/* Dsiplay results in a table */ Parse error: parse error, unexpected '{' in /public_html/pa/index.php on line 22 |
you didnt copy this code very well...
|
Quote:
|
:thumbsup found a few too:
Code:
echo "<table cellspacing='10' border=0' cellpadding='0' width='100%'?"; also the "?" at the end of it should be a ">" instead e.g: Code:
echo "<table cellspacing='10' border='0' cellpadding='0' width='100%'>"; |
Did you END the loop?
Code:
while ($row = mysql_fetch_array{result,MYSQL_ASSOC)) |
man your screwing it all up ... now you need a { after your while statement
|
Quote:
|
wow you guys are fast posters :)
|
Quote:
|
Added the loop, Even better, Thanks!
|
Not to mention, mysql_assoc_array($result)
would work for that section too. |
Quote:
|
One more quicky, how do I make it display Intersection1 & Intersection2 such as "Street1 & Street2" in the line :
echo "<td>".$row['intersection1']."</td>\n"; |
Quote:
Quote:
|
Quote:
|
Thanks again!
|
Didnt know ya were into PHP V!
Nice |
All times are GMT -7. The time now is 12:46 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123