Jump to content

Mysql connection in variable help


iJoseph

Recommended Posts

I have some code that makes a news article but I need it in a variable to add it to a template. I have the following:

<?php
$content = "
$db = mysql_connect(\"localhost\", \"user\", \"pass\");
mysql_select_db(\"inerdso1_ribz\",$db);
$result = mysql_query(\"SELECT * FROM news ORDER BY id DESC LIMIT 3\");
while ($row = mysql_fetch_array($result)) {
echo '
<table border=\"0\" width=\"50%\" id=\"table1\">
<tr>
<td width=\"196\"></td>
<td>Title: ' . $row['title'] . '</td>
</tr>
<tr>
<td width=\"196\" valign=\"top\">Author: ' . $row['author'] . '</td>
<td valign=\"top\">' . $row['message'] . '</td>
</tr>
</table>

';
} 
";
?>

But I keep getting the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/inerdso1/public_html/ribz/news.php on line 11

I don't know what toi do and would like it if you could help me.

Joseph

Link to comment
https://forums.phpfreaks.com/topic/188091-mysql-connection-in-variable-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.