Sagewire Logo

amazing syntax error

9 Message(s) by 8 Author(s) originally posted in php language


From: Dean Date:   Wednesday, December 28, 2005
Amazing. Maybe more a PHP problem.

This little phscript works perfect with PHP 5.0 and Mysql 5.0 ...under
Windows with IE and Netscape 8.0. Exactly the
same script gives a syntax error on line: b=<?=$rec?> (little green arrow
pointing to <?) with PHP 5.0 and Mysql 5.0
and Netscape 7.2 under Linux (redhat 9.0).

The script code :
<html>
<body>
<?php
$link = mysql_connect("localhost", "root", "pw")
or die("Impossible de se connecter : " . mysql_error());
$dbsel = mysql_select_db('mydb', $link);
$sql = "SELECT logon, number FROM mytable";
$result = mysql_query($sql);
$rec=mysql_num_rows($result);
echo $rec; // = 12
?>


<script type="text/JAVAscript">
b = <?=$rec?>; // error line
alert(b);
</script>

</body></html>(Variable $rec = 12 )

I really do not know what's wrong with this code ...
Do you?
Thanks
Dean


From: Ewoud Dronkert Date:   Wednesday, December 28, 2005
wrote in message :
<script type="text/JAVAscript">
b = <?=$rec?>; // error line
I really do not know what's wrong with this code ...



http://php.net/ini.core#ini.short-open-tag

--
E. Dronkert


From: Oli Filth Date:   Wednesday, December 28, 2005
Dean said the following on 28/12/2005 15:50:
Amazing. Maybe more a PHP problem.
This little phscript works perfect with PHP 5.0 and Mysql 5.0 ...under
Windows with IE and Netscape 8.0. Exactly the
same script gives a syntax error on line: b=<?=$rec?> (little green arrow
pointing to <?) with PHP 5.0 and Mysql 5.0
and Netscape 7.2 under Linux (redhat 9.0).
The script code:
<html>
<body>
<?php
$link = mysql_connect("localhost", "root", "pw")
or die("Impossible de se connecter : " . mysql_error());
$dbsel = mysql_select_db('mydb', $link);
$sql = "SELECT logon, number FROM mytable";
$result = mysql_query($sql);
$rec=mysql_num_rows($result);
echo $rec; // = 12
?>

<script type="text/JAVAscript">
b = <?=$rec?>; // error line
alert(b);
</script>
</body></html>
(Variable $rec = 12 )
I really do not know what's wrong with this code ...



Well, you have not said whether you're getting a PHP syntax error or a
JAVAScript error. If it's JAVAScript error, then the PHP hasn'thing to
do with it, and vice versa. Either way, it's nothing to do with MySQL
(this is evident from the fact that echo $rec; gives a value).

In future, please learn to narrow down the possible causes, and post to
appropriate groups accordingly, as well as snipping irrelevant bits of code.Note that whether you're able to use <?= ?> tags is
configuration-dependent, namely "short tags" option. Look it up in the
manual...

--
Oli


From: Hilarion Date:   Wednesday, December 28, 2005
wrote in message:

Amazing. Maybe more a PHP problem.
This little phscript works perfect with PHP 5.0 and Mysql 5.0 ...under
Windows with IE and Netscape 8.0. Exactly the
same script gives a syntax error on line: b=<?=$rec?> (little green arrow
pointing to <?) with PHP 5.0 and Mysql 5.0
and Netscape 7.2 under Linux (redhat 9.0).
The script code:
<html>
<body>
<?php
$link = mysql_connect("localhost", "root", "pw")
or die("Impossible de se connecter : " . mysql_error());
$dbsel = mysql_select_db('mydb', $link);
$sql = "SELECT logon, number FROM mytable";
$result = mysql_query($sql);
$rec=mysql_num_rows($result);
echo $rec; // = 12
?>

<script type="text/JAVAscript">
b = <?=$rec?>; // error line
alert(b);
</script>
</body></html>
(Variable $rec = 12 )
I really do not know what's wrong with this code ...
Do you?
Thanks
Dean



The error isn't related to PHP version, MySQL version, your OS or
(PHP errors never are) to the browser. The problem is probably
related to your PHP settings. In the first case (when the script
works) you've short tags turned on, and in the second case
you've short tag turned off.
Read about "short_open_tag" setting in "php.ini" (or --enable-short-tags
configuration directive).

In general usage of short tags is discouraged because it makes
your script less portable (it won't work with short tags turned
off).

Change this:

b = <?=$rec?>;

to this:

b = <?php echo $rec; ?>

and the script will work regardless of short tags being on or off.
(Also don't use "<?" instead of "<?php" - it's also a short tag,
not only "<?=").Hilarion


From: Dean Date:   Wednesday, December 28, 2005
Thanks for your friendly explanation."Hilarion" <hilarion@xxxxxxxxxxx> schreef in bericht

wrote in message:
Amazing. Maybe more a PHP problem.

This little phscript works perfect with PHP 5.0 and Mysql 5.0 ...under
Windows with IE and Netscape 8.0. Exactly the
same script gives a syntax error on line: b=<?=$rec?> (little green arrow
pointing to <?) with PHP 5.0 and Mysql 5.0
and Netscape 7.2 under Linux (redhat 9.0).

The script code:
<html>
<body>
<?php
$link = mysql_connect("localhost", "root", "pw")
or die("Impossible de se connecter : " . mysql_error());
$dbsel = mysql_select_db('mydb', $link);
$sql = "SELECT logon, number FROM mytable";
$result = mysql_query($sql);
$rec=mysql_num_rows($result);
echo $rec; // = 12
?>


<script type="text/JAVAscript">
b = <?=$rec?>; // error line
alert(b);
</script>

</body></html>

(Variable $rec = 12 )

I really do not know what's wrong with this code ...
Do you?
Thanks
Dean
The error isn't related to PHP version, MySQL version, your OS or
(PHP errors never are) to the browser. The problem is probably
related to your PHP settings. In the first case (when the script
works) you've short tags turned on, and in the second case
you've short tag turned off.
Read about "short_open_tag" setting in "php.ini" (or --enable-short-tags
configuration directive).
In general usage of short tags is discouraged because it makes
your script less portable (it won't work with short tags turned
off).
Change this:
b = <?=$rec?>;
to this:
b = <?php echo $rec; ?>
and the script will work regardless of short tags being on or off.
(Also don't use "<?" instead of "<?php" - it's also a short tag,
not only "<?=").


>
Hilarion


From: Gregory Nickoloff Date:   Tuesday, October 09, 2007
Are you saying it runs correctly on one server configuration but not the
other, or that the different configurations you mention are different client
setups being served?


From: Good Man Date:   Tuesday, October 09, 2007
wrote in message in


Are you saying it runs correctly on one server configuration but not
the other, or that the different configurations you mention are
different client setups being served?



that was an "amazing" thread pickup! last previous response, December
2005!!!


From: John Hosking Date:   Wednesday, October 10, 2007
wrote in message:
wrote in message in

Are you saying it runs correctly on one server configuration but not
the other, or that the different configurations you mention are
different client setups being served?
that was an "amazing" thread pickup! last previous response, December
2005!!!



He's improving; over in a.w.webmaster he's been responding to posts from
May of this year. If he keeps this up, in a week he will be replying to
threads from 1997.

:-P

--
John


From: David McKenzie Date:   Monday, October 15, 2007
wrote in message:
wrote in message:
wrote in message in

Are you saying it runs correctly on one server configuration but not
the other, or that the different configurations you mention are
different client setups being served?

that was an "amazing" thread pickup! last previous response, December
2005!!!
He's improving; over in a.w.webmaster he's been responding to posts from
May of this year. If he keeps this up, in a week he will be replying to
threads from 1997.
:-P


Re: WorldWideWeb: Summary
Dear Tim Berners-Lee,

Thanks for telling us about the WorldWideWeb, any idea when this will be
implemented?

Thanks,
Gregory Nickoloff

--
DM davidm@xxxxxxxxxxx

'It'd go against respecting principles and truth if you've to
respect and accept anything just because it is the other side's view.'
- Kim Jung Ill



Next Message: Want to get(retain) Last visited page


Blogs related to amazing syntax error

Lambda Expressions, Anonymous Methods, and Expression Trees
It is amazing that Visual Studio 2005 has only been out for just over two months ... It provides a more succinct syntax for assigning an anonymous method, ... You can’t just say getPart(6) anymore, you will receive a compile-time error. ...

GeoCool!
I am still loading the RSS feed myself from PHP because I want to get the ... There are an amazing number of things you can do with this API. ... And that included normal office interruptions and tracking down a dumb syntax error. ...

The World's Most Maintainable Programming Language: Part 5
Even if there were no other benefits, this would be an amazing point of value. ... In the real world it is an error to put five pounds of potatoes in a ten ... Given a simple syntax and core algebra, it may be possible to make this also ...

Off-Topic :: RE: The Psinetic Theory
The square root of 0 is a “syntax error” (says my calculator). It cannot be done. Therefore, the speed of light can never be ... You’d probably keep amazing track of time. Time is simply the reference of the order of the sequence of ...

Optimizing Apache and MySQL for Low Memory Usage, Part 2
Additionally, using the key buffer and the query cache are AMAZING performance ... Essentially, you’ll need to write a query that uses the SHOW syntax and uses the ... “too many connections” MySQL error, and your users won’t be happy. ...

Less is more: the hidden treasure of less command
Every time I work with less command, I find something new and amazing. less is capable ... Syntax error on line 53 of /etc/httpd/httpd.conf .... .. .... Ok let us display an error at line number 53 (no need to scroll down all 52 lines) ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional