You are here: Re: amazing syntax error « MySQL Databases « IT news, forums, messages
Re: amazing syntax error

Posted by Oli Filth on 12/28/05 18:02

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 don't know what's wrong with this code ...

Well, you haven't said whether you're getting a PHP syntax error or a
JavaScript error. If it's JavaScript error, then the PHP has nothing 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация