I have some html code that is supposed to be displayed by php echo. But for some reason i keep getting a syntax error, and i cant figure out what is going on.
Heres what i have -
<?php
-
if(isset($_GET['login'])) {
-
echo "<div id="visible">";
-
echo "<span onclick="swapform()">Log In Form</span>";
-
echo "</div>";
-
echo "<div id="theform" style="visibility: hidden">";
-
echo "<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">";
-
echo "<input type="text" value="Site Name" /><br />";
-
echo "<input type="submit" value="rub a dub" />";
-
echo "</form>";
-
echo "</div>";
-
}
-
?>
-
and my error message is - Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /www/110mb.com/t/h/e/j/e/t/p/a/thejetpage/htdocs/test/index.php on line 24
Line 24 is line 4 up there.
Is there anything wrong there? or is some code getting mixed up with the php code?
Thanks alot
--
Kestrel
4 22096 -
<?php
-
if(isset($_GET['login'])) {
-
echo "<div id=\"visible\">";
-
echo "<span onclick=\"swapform()\">Log In Form</span>";
-
echo "</div>";
-
echo "<div id=\"theform\" style=\"visibility: hidden\">";
-
echo "<form action=\"<?php echo $_SERVER['PHP_SELF']; ?>\" method=\"post\">";
-
echo "<input type=\"text\" value=\"Site Name\" /><br />";
-
echo "<input type=\"submit\" value=\"rub a dub\" />";
-
echo "</form>";
-
echo "</div>";
-
}
-
?>
-
The problem here looks like its a double quote conflict. You need to escape the double quotes with a backslash like this \", when they're in the string. The above version of your code should work. However, unless u're evalling this later on.. you'll get a html error when the <?php echo line is read... For that line I'd do this: -
eval ("<form action=\""<?php echo $_SERVER['PHP_SELF']; ?>"\" method=\"post\">");
-
Haven't checked that though, but you get the idea. My recent regex adventures with the e modifier may have confused my general eval syntax a little.
Good luck!
Sorry. Eval code for line 7 of your orignal code should be: -
eval ('?><form action="<?php echo $_SERVER[\'PHP_SELF\']; ?>" method="post">');
-
Use the single quotes to avoid a whitespace and T_ error. Translates the string as being literal. Also, you'll need to comment out the single quotes in that form 'PHP_SELF', so that it reads \'PHP_SELF\'.
I can confirm that the above works...
Try this instead: - "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">
Or better yet: -
echo <<<EOT
-
<div id="visible">
-
<span onclick="swapform()">Log In Form</span>
-
</div>
-
<div id="theform" style="visibility: hidden">
-
<form action="$_SERVER[PHP_SELF]" method="post">
-
<input type="text" value="Site Name" /><br />
-
<input type="submit" value="rub a dub" />
-
</form>
-
</div>
-
EOT;
-
http://www.php.net/manual/en/languag...syntax.heredoc
Remember that anything you echo goes straight to the browser, so putting PHP code in an echo statement won't cause it to get executed.
Thank you so much. I was ripping my hair out over this problem. I dont do php all that offen, and im about as good at php as Shaq is at free throw shooting. Anyways, thanks for your help guys.
-
Kestrel
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Salim |
last post by:
Hi people, keep getting this errorParse error: parse error, unexpected
T_STRING in order_fns.php line 91. the code is below for the file and
I've indicated line 91
<?php
function...
|
by: Anna MZ |
last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website:
$sql = "INSERT INTO 'users' ('userid', 'username', 'upassword')...
|
by: rhys |
last post by:
My Gurus and Angels --
Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
|
by: sclarkstone |
last post by:
Im getting this error;
Parse error: syntax error, unexpected T_STRING, expecting ':' or ';'
with this line;
header ('postcodesearch.php?e=nw&pcode=',);
I cant find whats wrong, can anyone...
|
by: Lawrence Krubner |
last post by:
Imagine a template system that works by getting a file, as a string, and
then putting it through eval(), something like this:
$formAsString = $controller->command("readFileAndReturnString",...
|
by: fburn |
last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux.
I receive an error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
|
by: paulrajj |
last post by:
hi to all,
i am getting syntax error on my code..
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\xampp\htdocs\Dummy\paulraj\matrim\exam.php on line 62
...
|
by: benicio |
last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19
I got this error and this syntax is from 8 to 19th line.
<?php
...
|
by: riverdale1567 |
last post by:
Hi I am a newbie trying to get some of my first code working, yada yada yada.
I have a drop down box which chooses a state then takes the post data to 'processform2.php' to use that to pull up...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| | |