Page 1 of 1

while array SQL problem

Posted: Wed May 31, 2006 8:47 pm
by a94060
Hi all ,i spent some time baking in front of my CRT and keep on getting this error:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/noob/public_html/admin/tabview.php on line 34

I read almost all concat guides and cant seem to find problem(i know its simpe for you all) HEre it is:

Code: Select all

echo '<table cellspacing=\"7\">';
		echo '<th>Offer Name</th>';
		echo'<th>User completing Offer</th>';
		echo'<th>Complete?</th>';
		
		while($array = mysql_fetch_array($result,MYSQL_ASSOC)) {
		echo '<tr>' .$array['offer_name']</tr>;//THIS IS LINE 34!!!!!!!!!!!!!!!!!!!!!
		echo '<tr>' .$array['username']</tr>;
		echo '<tr><a href=do.php?act=approve&entry='.$array['id']>Approve</a></tr>;//the link which allows us to approve the entry
		}
		echo '</table>';//closes the dynamic table
		echo '<br>';
		echo '<hr>'; //hrozontial rule
		echo 'Here are the offers that are completed:';
		
		$query = "SELECT * FROM coffers"
		$result = mysql_query($query);
		$hits = mysql_num_rows($result);
It must be a simple problem with concat or maybe something else i have done wrong( i think im trying to hard).

Posted: Wed May 31, 2006 8:59 pm
by Christopher
Perhaps you should broast yourself instead:

Code: Select all

echo '<tr>' . $array['offer_name'] . '</tr>';//THIS IS LINE 34!!!!!!!!!!!!!!!!!!!!!
                echo '<tr>' . $array['username'] . '</tr>';

Posted: Wed May 31, 2006 9:00 pm
by ambivalent
Errors on the following lines:

Code: Select all

echo'<th>User completing Offer</th>';  // need space between ' and echo
echo'<th>Complete?</th>';  //ditto

echo '<tr>' .$array['offer_name']</tr>;  //didn't close quotes or concat properly
echo '<tr>' .$array['username']</tr>;  //ditto
echo '<tr><a href=do.php?act=approve&entry='.$array['id']>Approve</a></tr>; //ditto


echo '<tr>'.$array['offer_name'].'</tr>'  //correct concat
a94060 wrote: I read almost all concat guides and cant seem to find problem
Use a text editor with syntax highlighting so that errors like this becomes more obvious.

Posted: Thu Jun 01, 2006 12:08 pm
by a94060
i used dreamweaver,maybe it does not highlight the problems in there?

Perhaps you should broast yourself instead:

Code: Select all

: 
                echo '<tr>' . $array['offer_name'] . '</tr>';//THIS IS LINE 34!!!!!!!!!!!!!!!!!!!!! 
                echo '<tr>' . $array['username'] . '</tr>';

i had put this here so you guys would know which line is 34, i put the ! so u might be able to find it easly should u need to.
[/quote]

Posted: Thu Jun 01, 2006 1:05 pm
by RobertGonzalez

Code: Select all

<?php
echo '<table cellspacing="7">';
echo '<th>Offer Name</th>';
echo '<th>User completing Offer</th>';
echo '<th>Complete?</th>';
               
while ($array = mysql_fetch_array($result,MYSQL_ASSOC)) 
{
    echo '<tr>' . $array['offer_name'] . '</tr>';
    echo '<tr>' . $array['username'] . '</tr>';
    echo '<tr><a href="do.php?act=approve&entry=' . $array['id'] . '">Approve</a></tr>';
}

echo '</table>';
echo '<br />';
echo '<hr />'; 
echo 'Here are the offers that are completed:';

$query = "SELECT * FROM coffers";
$result = mysql_query($query) or die("Could not get the data: " . mysql_error());
$hits = mysql_num_rows($result);
?>

Posted: Thu Jun 01, 2006 5:28 pm
by a94060
thanks man

Posted: Thu Jun 01, 2006 5:45 pm
by RobertGonzalez
You got it. Hope it helped.