|
|
|
CMS takes the work out of building interactive websites. |
PHP MySQL
|
Contents Free PHP MySQL ToolsIntroduction to PHP MySQL Creating a Database Create a Table Adding Data Displaying Data Editing Table Data Delete Table Data Altering Tables Advanced Multiple Selection FormsCreate a Simple Poll |
|
This code would be used on your PC for site development if you did not specify a username and password when you set up the MySQL server on windows. $link = mysql_connect("localhost");
Note: Some webhosts will require you to include server name and port settings in your connect statement. The configuration shown below will work with most servers: The actual code shows how to connect using the username and password option which is required when you access the server on the internet. This configuration is used when you require your users to log in to access form processing. If log in is not required just place the actual values in the connect query statement. If used without error trapping it would be followed by a semi colon.
Sample Login Form
<form method="POST" action="connect_server.php">
Error TrappingTo save you from constantly visiting the error log file to find problems in your code , you can make use of a simple error reporting function provided by the mysql server. Using it with the PHP die function will help to pinpoint problem areas in your code. The code shown below could be appended to the end of any mysql function statement. Replace the word function with the mysql function name. Example$link = mysql_connect("localhost",$_POST['username'],$_POST['password'])or die("Connect Error: ".mysql_error());
Closing the ConnectionIt is good practice to break the connection with the mysql server when operations have ceased. This simple procedure is accomplished with the line of code shown below: Download the ScriptsThe Birthdays Database management files can be downloaded in a zip file. The package contains an integrated db management system, with a simple login file and interface. To run the scripts on your PC you must have a localhost server installed along with PHP and the MySQL server. MySQL TutorialTo extend your knowledge of MySQL study the Docs and Tutorials at the official MySQL website. MYSQL.com
|
|
|
|
|
|
| HTML TOC | Web Design | Create a Website | |
PHP MySQL - Interactive Website Design Copyright © 2007