Jump to content

creating a mysql database with php problem


fireice87

Recommended Posts

Hey im just starting to learn php and mysql
im using xampp as my server
iv established a connection between php and mysql im trying to create a dataasbe by using php. but i keep getting this error

File not found
Firefox can't find the file at /C:/xampp/htdocs/<?php echo( $_SERVER['PHP_SELF'] ); ?>.

iv taken the code with only the slightest alterations (taken out the username and password) from a tutriol book the problem is the book has plenty of code samples but very little explanation. The code is below:

<?php
$conn = @mysql_connect("localhost", "root", "")
or die( "Sorry - could not connect to MYSQL" );

$rsl = @mysql_create_db( $_REQUEST['db'] );

$rs2 = @mysql_list_dbs( $conn );
for ( $row = o; $row < mysql_num_rows( $rs2 ); $row++ )
{ $list .= mysql_tablename( $rs2, $row) . " | ";
?>

<html><head><title>Create a database</title></head>
<body>
<form action = "<?php echo( $_SERVER['PHP_SELF'] ); ?>"
method="post">Current database:
<?php echo( $list ); ?>
<hr>Name: <input type = "text" name = "db">
<input type = "submit" value = "Create Database">
</form></body></html>

I know very little about php and cant see whats wrong with this as the book does not explain any help or links to tutorials would be great
thanks
better u follow this code.. this will help u...
<?php
include 'config.php';
include 'opendb.php';

$queryFile = 'myquery.txt';

$fp    = fopen($queryFile, 'r');
$query = fread($fp, filesize($queryFile));
fclose($fp);
$result = mysql_query($query);

include 'closedb.php';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.