WEIRD! error, dont know why, can anyone help?

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
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

WEIRD! error, dont know why, can anyone help?

Post by Mythic Fr0st »

Im getting a parse error somewhere in this line of code...

Code: Select all

if (!mysql_query($sql,$con))
  {
  die('<font color="red" size="4"><br/>Error: </font>' . mysql_error());
  }
<div align='center'>
echo '<font size=\'4\' color=\'blue\'>'Welcome to Mythic Aeons</font>';

mysql_close($con);
I dunno why?, someone plz help
Flamie
Forum Contributor
Posts: 166
Joined: Mon Mar 01, 2004 3:19 pm

Post by Flamie »

Code: Select all

echo '<font size=\'4\' color=\'blue\'>'Welcome to Mythic Aeons</font>';
change to

Code: Select all

echo '<font size=\'4\' color=\'blue\'>Welcome to Mythic Aeons</font>';
User avatar
pgolovko
Forum Commoner
Posts: 38
Joined: Sun Sep 17, 2006 9:13 am

Post by pgolovko »

Code: Select all

if(!mysql_query($sql,$con)){ 
  die("<font color=\"red\" size=\"4\"><br/>Error: </font>" . mysql_error()); 
  } 
echo "<div align=\"center\"><font size=\"4\" color=\"blue\">'Welcome to Mythic Aeons</font>"; 

mysql_close($con);
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Mythic Fr0st wrote:Im getting a parse error somewhere in this line of code...

Code: Select all

if (!mysql_query($sql,$con))
  {
  die('<font color="red" size="4"><br/>Error: </font>' . mysql_error());
  }
<div align='center'>
echo '<font size=\'4\' color=\'blue\'>'Welcome to Mythic Aeons</font>';

mysql_close($con);
I dunno why?, someone plz help
You are mixing PHP and HTML incorrectly, that is why. You either need to use PHP to output your HTML or you need to move into and out of HTML mode using your PHP code. Take what you have posted and turn it into this:

Code: Select all

<?php
if (!$result = mysql_query($sql,$con)) // makes sense to store the query result for use later, no?
{
  die('<font color="red" size="4"><br/>Error: </font>' . mysql_error());
}
echo '<div align="center">'; // This was your error
echo '<font size="4" color="blue">Welcome to Mythic Aeons</font>'; // This would have thrown errors as well

mysql_close($con);
?>
Also, might I suggest reviewing your code before or even as you post it? This is something that might have become evident to you as you look at it. And please try to use a more descriptive title to your posts. 'WEIRD! error, dont know why, can anyone help?' will make more people want to bypass your post than answer it.
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

Post by Mythic Fr0st »

I know, I usually give better ones, but didnt know what to put O_O, thanks though
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Maybe 'HELP NEEDED - I can't find the parse error in this code snippet'? Although PHP should have reported the error and location to you. Do you have display_errors set to 'On'?
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

Post by Mythic Fr0st »

Yea, it does show me the line
Post Reply