GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   php question (https://gfy.com/showthread.php?t=478683)

mkx 06-09-2005 02:58 AM

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

arnette 06-09-2005 03:04 AM

you need a " at the end of your echo

arnette 06-09-2005 03:04 AM

twice

...

woj 06-09-2005 03:09 AM

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...

arnette 06-09-2005 03:12 AM

Quote:

Originally Posted by woj
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...

this one too

echo "<tr>\n;

to:
echo "<tr>\n";

V_RocKs 06-09-2005 03:14 AM

No you didn't close the loop with a }

V_RocKs 06-09-2005 03:16 AM

Also, this is better written from,
Code:

echo "<td>{$row['intersection1']}</td>\n";
to
Code:

echo "<td>".$row['intersection1']."</td>\n";
And when you post code here, use code tags or we might not see what you typed.

Alky 06-09-2005 03:18 AM

Quote:

Originally Posted by V_RocKs
Also, this is better written from,
Code:

echo "<td>{$row['intersection1']}</td>\n";
to
Code:

echo "<td>".$row['intersection1']."</td>\n";
And when you post code here, use code tags or we might not see what you typed.

you edit fast, i was about to call you on your error :)

mkx 06-09-2005 03:22 AM

Still shows same error after changing to:

/* display row for each listingid */
echo "<tr>\n";
echo "<td>{$row['intersection1']}</td>\n";
?>

Alky 06-09-2005 03:23 AM

Quote:

Originally Posted by raulph
Still shows same error after changing to:

/* display row for each listingid */
echo "<tr>\n";
echo "<td>{$row['intersection1']}</td>\n";
?>

you need to close your while loop

put a } before the ?>

Alky 06-09-2005 03:24 AM

also
while ($row = mysql_fetch_array{result,MYSQL_ASSOC)) is wrong,

it should be
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))

mkx 06-09-2005 03:25 AM

Ok changed to:

Code:

/* 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";
?>

Now I get this error:


Parse error: parse error, unexpected '{' in /public_html/pa/index.php on line 22

Alky 06-09-2005 03:25 AM

you didnt copy this code very well...

mkx 06-09-2005 03:26 AM

Quote:

Originally Posted by Alky
also
while ($row = mysql_fetch_array{result,MYSQL_ASSOC)) is wrong,

it should be
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))

problem solved. Thanks!

Zester 06-09-2005 03:26 AM

:thumbsup found a few too:
Code:

echo "<table cellspacing='10' border=0' cellpadding='0' width='100%'?";
look at the "border" part, its missing a '
also the "?" at the end of it should be a ">" instead

e.g:
Code:

echo "<table cellspacing='10' border='0' cellpadding='0' width='100%'>";

V_RocKs 06-09-2005 03:26 AM

Did you END the loop?

Code:

while ($row = mysql_fetch_array{result,MYSQL_ASSOC))
{

/* display row for each listingid */
echo "<tr>\n;
echo "<td>{$row['intersection1']}</td>\n";
}

Notice the }

Alky 06-09-2005 03:26 AM

man your screwing it all up ... now you need a { after your while statement

mkx 06-09-2005 03:27 AM

Quote:

Originally Posted by Alky
you didnt copy this code very well...

Nope, for a second there I thought php for dummies was for dummies but now I realize I am the dummy. Thanks for everyones help :)

Zester 06-09-2005 03:27 AM

wow you guys are fast posters :)

Alky 06-09-2005 03:27 AM

Quote:

Originally Posted by Zester
e.g:
Code:

echo "<table cellspacing='10' border='0' cellpadding='0' width='100%'>";

html with ' is ugly

mkx 06-09-2005 03:28 AM

Added the loop, Even better, Thanks!

V_RocKs 06-09-2005 03:28 AM

Not to mention, mysql_assoc_array($result)
would work for that section too.

V_RocKs 06-09-2005 03:29 AM

Quote:

Originally Posted by Alky
man your screwing it all up ... now you need a { after your while statement

haha.. touche... }

mkx 06-09-2005 03:32 AM

One more quicky, how do I make it display Intersection1 & Intersection2 such as "Street1 & Street2" in the line :

echo "<td>".$row['intersection1']."</td>\n";

Alky 06-09-2005 03:34 AM

Quote:

Originally Posted by raulph
Ok changed to:

Code:

/* 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";
?>


Quote:

Originally Posted by V_RocKs
haha.. touche... }

i was going from that ;)

Alky 06-09-2005 03:35 AM

Quote:

Originally Posted by raulph
One more quicky, how do I make it display Intersection1 & Intersection2 such as "Street1 & Street2" in the line :

echo "<td>".$row['intersection1']."</td>\n";

echo "<td>".$row['intersection1'].$row['intersection2']."</td>\n";

mkx 06-09-2005 03:38 AM

Thanks again!

over911 06-09-2005 03:44 AM

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