Help - Search - Members - Calendar
Full Version: Parse error: parse error, unexpected T_ECHO
Hostony Board > General Support > PHP/MySQL
RAGEnCHAOS
Content-type: text/html X-Powered-By: PHP/4.3.4
Parse error: parse error, unexpected T_ECHO in C:\Documents and Settings\Administrator\Desktop\New File Site\$test.txt on line 3
Lines 1 - 11
CODE
<?php
$table = "$mod"
echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" align=\"center\">\n";
echo "<tr>\n";
echo "<td width=\"100%\" colspan=\"3\" class=\"attachheader\" align=\"center\"><b><span class=\"gen\">\n";
$result = mysql_query("select * from $table WHERE id = '$id'") or die(mysql_error());
while ($row = mysql_fetch_array($result))
 {
   echo $row["linkname"];
 }
echo "</span></b></td>\n";


as far as i can tell the code looks fine so i am totally lost :-(
Niakie
you forgot a semi-colon on line 2

lines 1 and 2 the way they should be...

CODE
<?php
$table = "$mod";


Thats should fix your problem
RAGEnCHAOS
omg doh i should have seen that !

thank you Niakie

im just now learning how to convert a normal html page to PHP hehe and so far i got 3 out of 15 so 12 to go hehe
Niakie
Not a problem, I was there at one time...

One sugestion I have for you (outside of remembering your semi-colons lol) is to use single quotes when you don't need to have verriables.

for example your code now:
CODE
echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" align=\"center\">\n";
echo "<tr>\n";


useing single quotes:
CODE
echo '<table width="95%" border="1" cellpadding="2" cellspacing="0" align="center">'."\n";
echo '<tr>'."\n";


The only thing you will need to escape this way are single quotes inside the string... Notice that I ended the string with a single quote, a dot then used double quotes for the new line... I find that this makes it easier to read... What I do if I need a varriable in the string is concatinate it so for example:

CODE
$message = 'Hello World';
echo 'My message today is: '.$message."\n";


There are a lot of good ideas and tips at Sitepoint as well... (right from beginner to super advanced lol) Make sure you check out their forums as well!
MartinB
try learning the "templates" methodology, is more clear when the html is completely separated from php code wink.gif

also, i see you don't have any php code-variable inside the html tags of your post, so you can close the ?> pure html here <? again.

CODE
echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" align=\"center\">\n";
echo "<tr>\n";


= to

CODE
phpblahblah;
?>
<table width="95%" border="1" cellpadding="2" cellspacing="0" align="center">
<tr>
<?
phpblahblah;
RAGEnCHAOS
nah i decided to go all echo and use switch statements and i olny wanted to just keep it simple by doing it the hard way to learn heheh start with a <?php and end with ?> and use it only 1 time heheh

you can see the design at http://www.ragenchaos.com

Enjoy i look forward to comments

Thanks Mike
Niakie
I get an error: Table 'ragencha_files.times' doesn't exist

The source code for the page looks like:
CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>RAGEnCHAOS.COM</title>
<link rel="StyleSheet" href="/css/main.css" type="text/css">
<style type="text/css">
@import url("/css/main.css")
</style>
</head>
<body bgcolor="#000000" text="#FFFFFF" background="/images/background.jpg">
Table 'ragencha_files.times' doesn't exist
RAGEnCHAOS
sorry was modfying the tables and you caught me at that moment hehe but its fixed now
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.
IPS Driver Error

IPS Driver Error

There appears to be an error with the database.
You can try to refresh the page by clicking here