Beginner here, need help with php to retrieve mysql data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rubenmr2
Forum Newbie
Posts: 1
Joined: Thu Apr 06, 2006 10:28 pm

Beginner here, need help with php to retrieve mysql data

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
Post Reply