• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

PHP Error

308holes

New Member
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:
//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:
use this:
PHP:
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);
 
Ok i tried this and getting erros still

PHP:
<?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);
?>
 
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>"

PHP:
<?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);
?>

this is the data in the MySQL Database
Code:
Webmaster    12:30:15PM   01/31/2003    Hello This is a Test
 
Last edited:
Now your not putting quotes ;)

PHP:
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
Code:
parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'

and the code im useing
PHP:
<?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);
?>
 
while($ROW = mysql_fetch_arry($RESULT))
replace with
while($ROW = mysql_fetch_array($RESULT))
 
Couldn't you use this?
PHP:
echo "<p>".$ROW['NAME']."</p>";
echo "<p>".$ROW['TIME']."</p>";
echo "<p>".$ROW['DATE']."</p>";
echo "<p>".$ROW['NEWS']."</p>";

Also, did you use capital letters when you made the row names? So it might be like this:
PHP:
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.:cry2: :)
 
Thats right Cyber-Scripter. 308holes , make sure you have the right variable name's and key's, $row['this'] is different from $ROW['THIS']...
 
Originally posted by 308holes
and the code im useing
PHP:
<?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);
?>

You forgot { and } :
print("<p>NAME:{$ROW['NAME']}</p>");
 
Could we please see the information that you put into PhpMyAdmin(I presume)? And Salam, why do you need curly brackets? I have never seen that method before...:confused:
 
The curlies arn't really needed in this case, they're used to print more complex statements, like $array[$i][$j]. The current code should be fine without them, but its advised to use them for anything more then a simple $var.
 
This is what I would like you to try:

PHP:
<?php
$link_id = mysql_connect( 'localhost', $dbuser, $dbuserpass);
mysql_select_db($dbname, $link_id);

   $query = "SELECT * from $dbtable";
   $result = mysql_query($query) or die(mysql_error());

     while($row = mysql_fetch_assoc($result))
     {
      //Place News in HTML Fields
         '<p>NAME:' . $row['name'] . '</p>';
        '<p>NAME:' . $row['time'] . '</p>';
        '<p>NAME:' . $row['date'] . '</p>';
        '<p>NAME:' . $row['news'] . '</p>';
     }
     mysql_close($link_id);
?>

Change what needs to be changed, but this will not fail without you getting a better error
 
This is what is in the Table
Code:
Name:Webmaster    Time:12:30:15PM   Date:01/31/2003    New:Hello 
This is a Test
thier all in Text Format
 
Have you tried the various echo'ing we have discussed so far 308holes?

And make sure your naming everything right, if you have your column named 'Name' then you have to get it with $row['Name'].
 
Back
Top