session and database code is displaying instead of values

Problems with the Windows version of XAMPP, questions, comments, and anything related.

session and database code is displaying instead of values

Postby Patty5 » 22. February 2010 20:17

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?
Patty5
 
Posts: 4
Joined: 22. February 2010 20:09

Re: session and database code is displaying instead of values

Postby WilliL » 22. February 2010 21:40

try insted <?php echo $_SESSION['myValue'] ?>
I think shorttags are switched OFF (standard in php5.3)
Willi
WilliL
 
Posts: 661
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: session and database code is displaying instead of values

Postby Altrea » 22. February 2010 21:44

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)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: session and database code is displaying instead of values

Postby Patty5 » 22. February 2010 21:53

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?
Patty5
 
Posts: 4
Joined: 22. February 2010 20:09

Re: session and database code is displaying instead of values

Postby Altrea » 22. February 2010 21:56

- 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
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: session and database code is displaying instead of values

Postby Patty5 » 22. February 2010 22:36

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???
Patty5
 
Posts: 4
Joined: 22. February 2010 20:09

Re: session and database code is displaying instead of values

Postby Altrea » 22. February 2010 22:46

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.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: session and database code is displaying instead of values

Postby Patty5 » 22. February 2010 22:48

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!
Patty5
 
Posts: 4
Joined: 22. February 2010 20:09

Re: session and database code is displaying instead of values

Postby Altrea » 22. February 2010 22:50

No Prob. You're welcome
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: session and database code is displaying instead of values

Postby MC10 » 23. February 2010 04:09

The ; doesn't actually comment the code out.
MC10
 
Posts: 148
Joined: 20. February 2010 20:13

Re: session and database code is displaying instead of values

Postby Altrea » 23. February 2010 06:13

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).
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: session and database code is displaying instead of values

Postby MC10 » 23. February 2010 20:46

I meant that for the code, it wasn't actually a comment, but actually code that ran.
MC10
 
Posts: 148
Joined: 20. February 2010 20:13


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 76 guests