Page 1 of 1

Beginner here, need help with php to retrieve mysql data

Posted: Thu Apr 06, 2006 10:47 pm
by rubenmr2
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello everyone, I am a beginner   , I need help with this simple php code.   I am trying to retrieve some data from a MySQL database, and I keep getting the same error.  

The error message that I get is:

Code: Select all

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /homepages/34/d155877179/htdocs/lunchantojitosframe.php on line 22

I am probably overlooking something really simple, but heres the code:
any help would be greatly appreciated, thanks in advance!


Code: Select all

<?php
@ $db = new mysqli('db341.perfora.net ', 'dbo376145627', 'Bg876cc2' 'db160310543');

if(mysqli_connect)errno())
{
echo 'Error: Could not connect to database.  Please try again later.';
exit;
}

$query = "select * from lunchmenu";
$result = $db->query($query);

$num_results = $result->num_rows;

for ($i=0; $i <$num_results; $i++)
{
	$row = $result->fetch_assoc();
	echo '<p><strong>'($row['item'])'</strong>';
	echo '<br /><center>'($row['description']);
	echo '<br /><center>'($row['price']);
	echo '</p>';
}

$result->free();
$db->close();
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Apr 06, 2006 11:16 pm
by feyd
Your echo's are culprits.

Code: Select all

echo '<p><strong>' . $row['item'] . '</strong>';
        echo '<br /><center>' . $row['description'];
        echo '<br /><center>' . $row['price'];
        echo '</p>';
Have a read through http://php.net/language.types.string