Warning: include(/home/cleancar/public_html/inc/site_header.php) [function.include]: failed to open stream: No such file or directory in /home/cleancar/public_html/index.php on line 2

Warning: include() [function.include]: Failed opening '/home/cleancar/public_html/inc/site_header.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cleancar/public_html/index.php on line 2


Warning: include(Assets/scripts/breadcrumbgen.php) [function.include]: failed to open stream: No such file or directory in /home/cleancar/public_html/index.php on line 4

Warning: include(Assets/scripts/breadcrumbgen.php) [function.include]: failed to open stream: No such file or directory in /home/cleancar/public_html/index.php on line 4

Warning: include() [function.include]: Failed opening 'Assets/scripts/breadcrumbgen.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cleancar/public_html/index.php on line 4

LAMP Setup


create mysql database & tables

create mysql database

create a table in mysql database:

	CREATE TABLE messages ( 
  	id int unsigned not null auto_increment primary key, 
  	name varchar(255), 
  	email varchar(255), 
  	message mediumtext 
        ); 

This creates a table with four columns:

  1. id: a numerical index that will be unique for each message
  2. name: a text field to hold the submitted name
  3. email: a text field to hold the submitted email address
  4. message: a larger text field for the message body

Demonstate form to database processor

php code for a feedback form tosave to database

<?php
   if (isset($_REQUEST['submit'])) { 
	   mysql_connect('localhost','myuser','mypassword'); 
	   mysql_select_db('mydb'); 
	   mysql_query("INSERT INTO messages (name,email,message) VALUES ('" . 
	   $_REQUEST['name'] ."','" . $_REQUEST['email'] . "','" . 
	   $_REQUEST['message'] . "')"); 
	   print "Thank you for the feedback."; 
   } else { 
	 print<<<_HTML_ 
	<form method="POST" action="$_SERVER[PHP_SELF]"> 
	<table>
       <tr><td>Name:</td><td><input type="text" name="name"></td></tr>
	<tr><td>Email:</td><td><input type="text" name="email"></td></tr>
	<tr><td>Message:</td><td><textarea name="message"></textarea></td></tr> 
	<tr><td colspan="2"><input name="submit" type="submit"></td></tr> 
	</form> 
  _HTML_;
  } 
?>

connecting to a table in mysql database:

Connect to database by running the mysql command-line utility with the database, username, and password you created earlier:
% mysql mydb -umyuser -pmypassword

general connection string in php code:
$dbh=mysql_connect ("localhost", "username", "<password>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("databasename");

Preferred method:


Warning: include(/home/cleancar/public_html/inc/site_sidecolumns.php) [function.include]: failed to open stream: No such file or directory in /home/cleancar/public_html/index.php on line 76

Warning: include() [function.include]: Failed opening '/home/cleancar/public_html/inc/site_sidecolumns.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cleancar/public_html/index.php on line 76

Warning: include(/home/cleancar/public_html/inc/site_footer.php) [function.include]: failed to open stream: No such file or directory in /home/cleancar/public_html/index.php on line 77

Warning: include() [function.include]: Failed opening '/home/cleancar/public_html/inc/site_footer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cleancar/public_html/index.php on line 77