PHP guestbook in jQuery Mobile

More
11 years 10 months ago - 10 years 8 months ago #12392 by illy
Hi,

This is my first try at PhP and I'm kind of stuck here.
I am creating a simple site with Jquery Mobile and am trying to include a PhP guestbook.
So far I got the original guestbook working, but when I include it in my Mobile site using:
Code:
<?php include 'gastenboek/list.php'; ?>

All the questbook buttons stop working and I get three error-messages.
The first two are:
Code:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/vhosts/an-en-eel-trouwen.nl/httpdocs/test/index.php:135) in /var/www/vhosts/an-en-eel-trouwen.nl/httpdocs/test/gastenboek/header.php on line 2
and
Code:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/vhosts/an-en-eel-trouwen.nl/httpdocs/test/index.php:135) in /var/www/vhosts/an-en-eel-trouwen.nl/httpdocs/test/gastenboek/header.php on line 2
And the second is:
Code:
Non Numeric Page Number
I tried finding a solution on the web, but I'm a bit stuck here.
Can anybody help me out?
Last edit: 10 years 8 months ago by Pete.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago - 10 years 8 months ago #12393 by Pete
Replied by Pete on topic PhP guestbook in Jquery Mobile
Hello illy,

The guestbook was not designed to be included, so there are several problems with your approach.

1. Session Start Problem - If you look at the header.php source code on line 2, you will see this:
Code:
<?php session_start(); ?>

What basically happens when you include the list.php file in your code is that by the time the header.php file gets included you already have HTML output on on your page which means you can no longer start the PHP Session since there is already HTML code rendered to the browser. To fix this you will have to remove the code block above from the header.php file, and include it at the very top of your Mobile Site file BEFORE you output any other HTML.

2. Page Number Problem - The way the list.php file works is that it expects to receive two URL parameters called "page" and "order" in the format "list.php?page=1&order=asc". When you include the file "list.php", it is essentially the equivalent of calling the file "list.php" without any parameters, so the code complains that the parameters it is expecting do not exist (and rightfully so). To fix this, you will have to take out code lines 5 and 6 in list.php and set the $page and $order values inside your main Mobile file BEFORE you include the list.php file. Of course you will now have to pass the same two parameters to "index.php" file in order for the listing page paging to function.

3. Inclusion Path Problem - Let say you include the "list.php" file from a file called "index.php", which resides here:
Code:
test/index.php

From there you include the guestbook list.php file, which is here:
Code:
test/gastenboek/list.php

This effectively puts the header.php file base one folder level up from where it was. So when the file list.php tries to include the file "header.php", it will now be looking here:
Code:
test/header.php

But where it should be looking is here:
Code:
test/gastenboek/header.php

So to fix this, all you have to do is to go through the code and wherever you find an include statement you would change it to "gastenboek/[Name Of The File].php".

There may be other issues, but this will get you started. Normally we recommend users to include the guestbook using an iframe in order to spare them from having to make the above modifications, unless they understand PHP and are willing to work on the changes.

Pete

DigiOz Webmaster
www.digioz.com
Last edit: 10 years 8 months ago by Pete.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #12394 by illy
Replied by illy on topic PhP guestbook in Jquery Mobile
Hi Pete,

Thanx for your answer!
It is starting to make a bit of sense now.
I will see if I can fix my problems.

I tried using an iframe at first, but because I am making a mobile site I couldn't get the sizes correct.

Please Log in or Create an account to join the conversation.

Time to create page: 0.117 seconds
Powered by Kunena Forum