[Home]   i n s t r u c t i o n s
< back to index       PHP
 
i n f o
   about us
   technical
   payment
   contact

s e r v i c e s
   packages
   server
   design
   sign up

s u p p o r t
   instructions
   F.A.Q.
   password

m i s c
   resellers
   offers
   free

h o m e

  PHP is a powerful server-side scripting language, using commands embedded in html. It can communiate directly with a MySQL database.

Because of the insecure nature of mod_php3, we support php as CGI instead. To use a standard *.php file, you need to add one line at the top:
#!/usr/local/bin/php
and follow all the other steps for CGI scripts (use ASCII mode ftp, and make it executable by setting permissions to mode 700).

An example of a simple php3 test script
#!/usr/local/bin/php
<?php phpinfo()?>

An example of communicating with a MySQL database
Note: you must change the port "12345" to match the tcp port your MySQL server listens on.

 
#!/usr/local/bin/php 
<? 
$conn=mysql_connect("127.0.0.1:12345"); 
if(!mysql_select_db("test",$conn)){echo ("Cannot select database.\n");} 
$sql="create table phptest (php char(20), test char(20))"; 
if(!mysql_query($sql,$conn)) 
  { 
  echo ("Error creating test table.\n"); 
  }else{ 
  echo ("test table created.\n"); 
  }  
$sql="insert into phptest values('this is a','test insert')"; 
if(!mysql_query($sql,$conn)) 
  { 
  echo ("Error Inserting data into test table.\n"); 
  }else{ 
  echo ("Data inserted to test table.\n"); 
  } 
$sql="select * from phptest"; 
if(!($result=mysql_query($sql,$conn))) 
  { 
  echo ("Error selecting data from test table.\n"); 
  }else{ 
  echo ("Data selected from test table.\n"); 
 
  while(($data=mysql_fetch_row($result))){ 
    echo("$data[0] $data[1]\n"); 
    } 
   
  } 
 
 
$sql="delete from phptest where test like 'test%'"; 
if(!mysql_query($sql,$conn)) 
  { 
  echo ("Error deleting data from test table.\n"); 
  }else{ 
  echo ("Data deleted from test table.\n"); 
  } 
if(!mysql_query($sql,$conn)) 
  { 
  echo ("Error Inserting data into test table.\n"); 
  }else{ 
  echo ("Data inserted to test table.\n"); 
  } 
$sql="drop table phptest"; 
if(!mysql_query($sql,$conn)) 
  { 
  echo ("Error deleting test table.\n"); 
  }else{ 
  echo ("test table deleted.\n"); 
  } 
mysql_close($conn); 
?> 

For more information on programming with PHP, please see the official documentation here.

 

 
TOPICS
getting started
domain registration | mail forwarding | checking mail | uploading your site
basic features
web stats | hit counters | form-to-mail cgi | redirect cgi | autoresponders |
basic mailing lists | advanced mailing lists | search engine submission | frontpage extensions | password protected directory | custom error pages | subdomains
advanced features
cgi scripts | server-side includes | php | mysql |

 
All your hosting dreams come true!
P R O F E S S I O N A L
hkhosting.com
W E B   S E R V I C E S

Copyright © 1999-2003 HK Hosting Ltd. All rights reserved. Terms & Conditions