Hi:

I am working on a computer with RedHat Linux 7.2
I am running Apache web server and MySQL and Netscape browser
I am working local as the root

I am working through exercises from the book
PHP Essentials 1st edition by Julie C Meloni.

I am having difficulty with an exercise
in chapter 4 regarding Create a Database Table.

I was receiving a Couldn't connect to server.
in Netscape.

I edited script error and now I am stuck
with Couldn't execute query.

So I guess I am able to connect to the server
and the database, but not execute the query.

The following is the do_creatable.php script:

<?php

$sql = "CREATE TABLE $table_name (";

for ($i = 0; $i < count($field_name); $i++) {

$sql .= "$field_name[$i] $field_type[$i]";

                if ($field_length[$i] != "") {
                        $sql .= " ($field_length[$i]),";
                } else {
                        $sql .= ",";
                }
        }

$sql = substr($sql, 0, -1);

$sql .= ")";

        $connection = mysql_connect("hostname","username","password")
                or die("Couldn't connect to server.");

        $db = mysql_select_db("database_name", $connection)
                or die("Couldn't select database.");

        $sql_result = mysql_query($sql,$connection)
                or die("Couldn't execute query.");

        if (!$sql_result) {
                echo "<P>Couldn't create table!";
        } else {
                echo "<P>$table_name has been created!";
        }
?>

_________________________________________________________________
Let the new MSN Premium Internet Software make the most of your high-speed experience. http://join.msn.com/?pgmarket=en-us&page=byoa/prem&ST=1


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to