This topic should become the PHP and MySQL FAQ. If you have any suggestions post them and I'll update this post. Please post them in the same format I am using to make it easy for me.
All code here is written for PHP5 because frihost supports that on all servers and because php4 isn't used a lot any more.
How do I use XML with PHP?
First put all the data in a variable (ie. with fopen). Then use SimpleXML to make an object of the xml file.
How do I use cookies?
To set a cookie use setcookie. To read the cookie use $_COOKIE['var'].
this will output: value
Note that you can only set cookies before sending any output to the user.
How do I use sessions?
At the beginning of every PHP file where you want to use sessions use this code before you send any output to the user (of course after the php opening tag):
Now you can use $_SESSION as a normal array. You can store stuff in it and it will be in the session array untill the session has expired or the user closed the browser.
Does frihost have extension x enabled?
To see all the info about the frihost php installation take a look at the php info pages. The info pages for server 1, server 2 and server 3. New accounts are created on server 1. If you want to know on what server you are on pm a mod or admin.
How do I start with PHP?
Read through these topics before asking questions. They can help you get started:
http://www.frihost.com/forums/vt-87990.html
http://www.frihost.com/forums/vt-87603.html
Where can I get good PHP documentation?
The PHP group has an extended PHP manual with user contributed notes. It's available in both online format and downloadable version at http://www.php.net/docs.php
Can you help me with my PHP script? There's something wrong with it!
Yes, most of Frihost users will help. But remember to provide with a detailed description of the problem and a copy of the script. The more info you provide, the faster you'll get help.
Last edited by rvec on Thu May 08, 2008 12:30 pm; edited 1 time in total
All code here is written for PHP5 because frihost supports that on all servers and because php4 isn't used a lot any more.
| Code: |
| [size=18]Question?[/size]
Answer |
How do I use XML with PHP?
First put all the data in a variable (ie. with fopen). Then use SimpleXML to make an object of the xml file.
How do I use cookies?
To set a cookie use setcookie. To read the cookie use $_COOKIE['var'].
this will output: value
| Code: |
| setcookie("TestCookie", 'value');
echo $_COOKIE["TestCookie"]; |
How do I use sessions?
At the beginning of every PHP file where you want to use sessions use this code before you send any output to the user (of course after the php opening tag):
| Code: |
| session_start() |
Now you can use $_SESSION as a normal array. You can store stuff in it and it will be in the session array untill the session has expired or the user closed the browser.
Does frihost have extension x enabled?
To see all the info about the frihost php installation take a look at the php info pages. The info pages for server 1, server 2 and server 3. New accounts are created on server 1. If you want to know on what server you are on pm a mod or admin.
How do I start with PHP?
Read through these topics before asking questions. They can help you get started:
http://www.frihost.com/forums/vt-87990.html
http://www.frihost.com/forums/vt-87603.html
Where can I get good PHP documentation?
The PHP group has an extended PHP manual with user contributed notes. It's available in both online format and downloadable version at http://www.php.net/docs.php
Can you help me with my PHP script? There's something wrong with it!
Yes, most of Frihost users will help. But remember to provide with a detailed description of the problem and a copy of the script. The more info you provide, the faster you'll get help.
Last edited by rvec on Thu May 08, 2008 12:30 pm; edited 1 time in total
