|
The following shows a simple example of how PHP can create
a table in a database on a MySQL server, and can create entries
in a table, then recalling it, and then finally deleting the
table. The table below contains real PHP code on the right-hand
side, but you cannot see it because it has been processed
by the server.
|
PHP
|
Executed Code
|
Creating a table in a database
|
<?php
/* Start of PHP3 Script */
/* Data of SQL-server */
$server= "$$$$"; /* Address of server */
$user= "$$$"; /* FTP-username */
$password= "$$$"; /* FTP-Password */
$database= "$$$"; /* name of database */
$table= "datatest"; /* Name of table, you
can select that */
/* Accessing the server and creating the table */
MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server
unreachable</H3>");
MYSQL_SELECT_DB($database) or die ( "<H3>database
not existent</H3>");
$result=MYSQL_QUERY( "CREATE TABLE $table (name
varchar(25),email varchar(25))");
print "Result is $result";
/* Terminate SQL connection*/
MYSQL_CLOSE();
?>
|
Fatal error: Call to undefined function MYSQL_CONNECT() in E:\kunden\homepages\29\d390184582\www\php_database.php on line 136
| |