Page 1 of 1

session and database code is displaying instead of values

PostPosted: 22. February 2010 20:17
by Patty5
I recently reformated my computer after running xampp successfully. I have recentely installed the newest version of XAMPP. I am pulling database values and session values and neither of these values display on the pages. All that displays is the code to display them. For example, in a text box, instead of displaying a session value, the code <?=$_SESSION['myValue'];?> displays instead. The same for database values.

Is there a way to fix these please?

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 21:40
by WilliL
try insted <?php echo $_SESSION['myValue'] ?>
I think shorttags are switched OFF (standard in php5.3)

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 21:44
by Altrea
You are using short_open_tags. Since release PHP 5.3 the Default Value for short_open_tag in the php.ini is Off.

- Use <?php instead of <? for the beginning of your php-section and <?php echo instead of <?=
- or switch on php_open_tags in the php.ini file (which i don't recommend)

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 21:53
by Patty5
Thank you for the reply!

ALL my files use <?=$_SESSION['whatever'];?> style. How do I switch on php_open_tags in php.ini in xampp?

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 21:56
by Altrea
- Open php.ini file (there is only one inside your php folder)
- search for the short_open_tag flag
- change the flag from Off to On
- save the file
- restart your Apache

very detailed :D

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 22:36
by Patty5
Ok....

php.ini now reads

short_open_tag
Default Value: On
Development Value: On
Production Value: On

I took out all the ; before each line and restarted Apache.

Now, it doesn't seem to want to accept my mysql connection as I am getting this error

Fatal error: Call to undefined function mysql_connect() in C:\xampp\htdocs\pathtoMyConnectionString on line 3

This line 3 in my code reads:

$myConnection=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error());

All this worked previous is other xaampp and also works when I change the values and upload to live server so I am assuming I need to change something else in php.ini???

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 22:46
by Altrea
Patty5 wrote:php.ini now reads

short_open_tag
Default Value: On
Development Value: On
Production Value: On

I took out all the ; before each line and restarted Apache.



comment the lines as it was default.

in php.ini file line ~226 is the short_open_tag flag
You simply had to change Off to On. No uncommeting.

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 22:48
by Patty5
Yes, I saw that just before I got your notification. Sorry... stupid as an ass for not looking further down. I restarted Apache and all works fine now!

Thanks SO much for your help!

Re: session and database code is displaying instead of values

PostPosted: 22. February 2010 22:50
by Altrea
No Prob. You're welcome

Re: session and database code is displaying instead of values

PostPosted: 23. February 2010 04:09
by MC10
The ; doesn't actually comment the code out.

Re: session and database code is displaying instead of values

PostPosted: 23. February 2010 06:13
by Altrea
MC10 wrote:The ; doesn't actually comment the code out.


You are wrong. The Semicolon in ini-files is the correct char to comment lines out.
And uncommenting the wrong lines out in the php.ini can produce some unexpected errors (php parser errors, and if you ignore them, syntax errors like missing php functions as well).

Re: session and database code is displaying instead of values

PostPosted: 23. February 2010 20:46
by MC10
I meant that for the code, it wasn't actually a comment, but actually code that ran.