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
nigma
DevNet Resident
Posts: 1094 Joined: Sat Jan 25, 2003 1:49 am
Post
by nigma » Fri Apr 25, 2003 7:28 pm
Hey, I get an error when I run this:
Code: Select all
<?php
$dbConn = mysql_connect("localhost", "user", "pass");
if (!$dbConn)
{
echo("Failed to connect to MySQL server.");
exit();
}
if (!@mysql_select_db("user"))
{
echo("Failed to select MySQL database..");
exit();
}
$q = "select * from users";
$result = mysql_query($q);
echo <<<BTABLE
<table border="0" width=50%>
<tr><th>User ID:</th><th>User Password:</th><th>Account Created:</th></tr>
BTABLE;
if (!$result)
{
echo("Failed to select users from MySQL database.");
exit();
}
while ($row = mysql_fetch_array($result))
{
echo '<tr><td>' . $rowї"user_id"] . '</td><td>' . $rowї"password"] . '</td><td>' . $rowї"created"] . '</td>';
echo("<td><a href="deleteUser.php?user_id=" . $rowї"user_id"] . "">Delete User</a></td></tr>");
}
echo <<<ETABLE
</table>
ETABLE;
?>
I am trying to familiarize myself with the MySQL functions, but obviously I haven't gotten to far.
Thanks for any help provided.
patrikG
DevNet Master
Posts: 4235 Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK
Post
by patrikG » Fri Apr 25, 2003 8:29 pm
And the error is?
nigma
DevNet Resident
Posts: 1094 Joined: Sat Jan 25, 2003 1:49 am
Post
by nigma » Fri Apr 25, 2003 8:32 pm
I got it working, there was a problem with these sections:
echo <<<BTABLE
//code
BTABLE;
echo <<<ETABLE
//code
ETABLE;
I don't actually know why that was causing an error, that exact code worked in a diff script but not in this one.
Do you know if there is a search engine that will let you look up the php error and it will tell you what the problem is?
Thanks
patrikG
DevNet Master
Posts: 4235 Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK
Post
by patrikG » Fri Apr 25, 2003 8:43 pm
Do you know if there is a search engine that will let you look up the php error and it will tell you what the problem is?
Not meaning to be flippant or anything, but that search-engine is a programmer's brain.
nigma
DevNet Resident
Posts: 1094 Joined: Sat Jan 25, 2003 1:49 am
Post
by nigma » Fri Apr 25, 2003 8:45 pm
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /Path/To/File.
So someone with a brain and some common sense who is new to php is supposed to be able to understand what this means?
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Fri Apr 25, 2003 8:50 pm
nigma wrote: Do you know if there is a search engine that will let you look up the php error and it will tell you what the problem is?
The human brain is the one i recommend too. I can't give you a URL though...
Hey i did find this helpful site that *might* help for this type of thing...
PHP Knowledgebase
patrikG
DevNet Master
Posts: 4235 Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK
Post
by patrikG » Fri Apr 25, 2003 8:59 pm
Oromian, is that really Maria Carrey?
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Sat Apr 26, 2003 5:21 am
nigma wrote: I got it working, there was a problem with these sections:
echo <<<BTABLE
//code
BTABLE;
echo <<<ETABLE
//code
ETABLE;
I don't actually know why that was causing an error, that exact code worked in a diff script but not in this one.
When you are using here doc format (your <<<BTABLE ... BTABLE;) making a mistake can cause any number of different errors, have a read of this (especially the warning
):
http://uk.php.net/manual/en/language.ty ... ax.heredoc
Mac