use this:
PHP Code:while($ROW = mysql_fetch_arry($RESULT))
{
//Place News in HTML Fields
echo "<p>NAME:$ROW[NAME]</p>
<p>TIME:$ROW[TIME]</p>
<p>DATE:$ROW[DATE]</p>
<p>NEWS:$ROW[NEWS]</p>";
}
mysql_close($LINK);
Hello all im having a problem it saying i have a error on my code and i dont know what it is.... says line17.. Please help
PHP Code://News.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Lemo News</TITLE>
<LINK REL=stylesheet HREF='ikonboard.css' TYPE='text/css'>
</HEAD>
<BODY BGCOLOR=49525D BACKGROUND="hardwired_bak.gif" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<?php
require("VAR.php");
$LINK = mysql_connect($HOST,$USER,$PASSWORD);
$QUERY = "SELECT * from $DBTABLE";
$RESULT = mysql_db_query($DBNAME,$QUERY,$LINK);
while($ROW = mysql_fetch_arry($RESULT))
{
//Place News in HTML Fields
<p>NAME:$ROW[NAME]</p>
<p>TIME:$ROW[TIME]</p>
<p>DATE:$ROW[DATE]</p>
<p>NEWS:$ROW[NEWS]</p>
}
mysql_close($LINK);
?>
</BODY>
</HTML>
//VAR.php
<?php
$HOST = "localhost";
$USER = "NAME";
$PASSWORD = "PW";
$DBNAME = "News";
$DBTABLE = "DBNews"
?>
Last edited by 308holes; February 3rd, 2003 at 01:54.
Sic vis pacem para bellum
"If You Want Peace Prepare For War"
use this:
PHP Code:while($ROW = mysql_fetch_arry($RESULT))
{
//Place News in HTML Fields
echo "<p>NAME:$ROW[NAME]</p>
<p>TIME:$ROW[TIME]</p>
<p>DATE:$ROW[DATE]</p>
<p>NEWS:$ROW[NEWS]</p>";
}
mysql_close($LINK);
There are 3 kinds of people: the ones who can count and the others who cannot
make sure you put quotes around the array names ($ROW['NAME']).
And also { and } : "<p>{$ROW['NAME']}</p>"
Ok i tried this and getting erros still
PHP Code:<?php
require("VAR.php");
$LINK = mysql_connect($HOST,$USER,$PASSWORD);
$QUERY = "SELECT * from $DBTABLE";
$RESULT = mysql_db_query($DBNAME,$QUERY,$LINK);
while($ROW = mysql_fetch_arry($RESULT))
{
//Place News in HTML Fields
<p>NAME:{$ROW['NAME']}</p>
<p>TIME:{$ROW['TIME']}</p>
<p>DATE:{$ROW['DATE']}</p>
<p>NEWS:{$ROW['NEWS']}</p>
}
mysql_close($LINK);
?>
Sic vis pacem para bellum
"If You Want Peace Prepare For War"
You're still missing the "echo" in the while loop!
a.aimoo.com - Get your forum reviewed here!
desilva.biz - Great webmaster tips and tricks!
webmaster-talk.com - Discussion forum for all webmasters
Yes, you are still missing the echo, but if it still produces errors, it may be the data your trying to print --if the content in "news" contained quotations, then it will cause an error, so it might be best to use htmlspecialchars() to escape the spcial HTML that may be inside of the variables.
The Variables are all Formatted as Text and i get an error on the first p tag"<p>NAME:{$ROW['NAME']}</p>"
this is the data in the MySQL DatabasePHP Code:<?php
require("VAR.php");
$LINK = mysql_connect($HOST,$USER,$PASSWORD);
$QUERY = "SELECT * from $DBTABLE";
$RESULT = mysql_db_query($DBNAME,$QUERY,$LINK);
while($ROW = mysql_fetch_arry($RESULT))
{
//Place News in HTML Fields
print(<p>NAME:$ROW['NAME']</p>);
print(<p>TIME:$ROW['TIME']</p>);
print(<p>DATE:$ROW['DATE']</p>);
print(<p>NEWS:$ROW['NEWS']</p>);
}
mysql_close($LINK);
?>
Code:Webmaster 12:30:15PM 01/31/2003 Hello This is a Test
Last edited by 308holes; February 4th, 2003 at 16:55.
Sic vis pacem para bellum
"If You Want Peace Prepare For War"
Now your not putting quotes
PHP Code:print "<p>NAME:$ROW['NAME']</p>";
print "<p>TIME:$ROW['TIME']</p>";
print "<p>DATE:$ROW['DATE']</p>";
print "<p>NEWS:$ROW['NEWS']</p>";
Ok THis is the Error i get now
and the code im useingCode:parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
PHP Code:<?php
require("VAR.php");
$LINK = mysql_connect($HOST,$USER,$PASSWORD);
$QUERY = "SELECT * from $DBTABLE";
$RESULT = mysql_db_query($DBNAME,$QUERY,$LINK);
while($ROW = mysql_fetch_arry($RESULT))
{
//Place News in HTML Fields
print("<p>NAME:$ROW['NAME']</p>");
print("<p>TIME:$ROW['TIME']</p>");
print("<p>DATE:$ROW['DATE']</p>");
print("<p>NEWS:$ROW['NEWS']</p>");
}
mysql_close($LINK);
?>
Sic vis pacem para bellum
"If You Want Peace Prepare For War"
while($ROW = mysql_fetch_arry($RESULT))
replace with
while($ROW = mysql_fetch_array($RESULT))
Code:parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
Sic vis pacem para bellum
"If You Want Peace Prepare For War"
Couldn't you use this?
Also, did you use capital letters when you made the row names? So it might be like this:PHP Code:echo "<p>".$ROW['NAME']."</p>";
echo "<p>".$ROW['TIME']."</p>";
echo "<p>".$ROW['DATE']."</p>";
echo "<p>".$ROW['NEWS']."</p>";
I no expert though, just a beginner.PHP Code:echo "<p>".$ROW['name']."</p>";
echo "<p>".$ROW['time]."</p>";
echo "<p>".$ROW['date']."</p>";
echo "<p>".$ROW['news]."</p>";
![]()
![]()
Never ever pet the monkey....[/URL]
Thats right Cyber-Scripter. 308holes , make sure you have the right variable name's and key's, $row['this'] is different from $ROW['THIS']...
You forgot { and } :Originally posted by 308holes
and the code im useing
PHP Code:<?php
require("VAR.php");
$LINK = mysql_connect($HOST,$USER,$PASSWORD);
$QUERY = "SELECT * from $DBTABLE";
$RESULT = mysql_db_query($DBNAME,$QUERY,$LINK);
while($ROW = mysql_fetch_arry($RESULT))
{
//Place News in HTML Fields
print("<p>NAME:$ROW['NAME']</p>");
print("<p>TIME:$ROW['TIME']</p>");
print("<p>DATE:$ROW['DATE']</p>");
print("<p>NEWS:$ROW['NEWS']</p>");
}
mysql_close($LINK);
?>
print("<p>NAME:{$ROW['NAME']}</p>");
Bookmarks