Kath,
Thank you, I completely forgot to strip the UserID and Password to MySQL.
The book is called PHP, Fast & Easy Web Development by Julie C. Meloni. The
errata is located at the somewhat famous www.thickbook.com (more
specifically http://www.thickbook.com/books/index.phtml, the book is the
first book listed on that page). The errata was helpful in some situations
where mistakes were noticable, but it doesn't go any further and it didn't
help solve the current problem I'm having. Perhaps I could have made a
mistake in the coding, who knows. All I know is that I tried checking and
rechecking my code and it looks fine to me. It is also the exact script from
the book, yet with the errata's corrections applied as well. Any help from
you or any of our other collegues on this newsgroup would be helpful. Thank
you for your response and attempt to help.
Navid Yar
-----Original Message-----
From: Kath [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 19, 2001 4:06 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] Authentication
In the future, do not post your mysql password on the list
Just a little piece of advice ;)
Also, try checking the online errata for the book (You didn't mention which
book so I can't point you in the right direction).
- Kath
----- Original Message -----
From: "Navid Yar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 19, 2001 4:59 PM
Subject: [PHP] Authentication
> Hello,
>
> I'm somewhat new to PHP. I'm having problems with a script and I don't
know
> why. It is from a book, yet it does not work for some reason. Both Apache
> and MySQL are on and are working fine on my system. The code deals with
> creating tables within a database (the database already exists. The error
is
> that it could connect to the database, but couldn't create the table
within
> the specified DB. Below are two PHP files that work together for this
> specific project. Any help with this is much appreciated. Here are the
> scripts:
>
> Script #1
>
>
> <?php
>
> // Check that the user entered the info. If not then direct them back to
the
> form
>
> if ((!$table_name) || (!$num_fields)) {
> header ("Location:
>
http://localhost/examples/dynamic/authentication/auth_app/show_createtable.h
> tml");
> exit;
> }
>
> $form_block = "<form method=\"post\" action=\"do_createtable.php\">
> <input type=\"hidden\" name=\"table_name\"
> value=\"$table_name\">
> <table cellspacing=\"5\" cellpadding=\"5\">
> <tr>
> <th>FIELD NAME</th><th>FIELD TYPE</th><th>FIELD
> LENGTH</th></tr>
> ";
>
> for ($i = 0; $i < $num_fields; $i++) {
>
> $form_block .= "<tr>
> <td align=\"center\"><input type=\"text\"
> name=\"field_name[]\" size=\"30\"></td>
>
> <td align=\"center\">
> <select name=\"field_type[]\">
> <option value=\"char\">char</option>
> <option value=\"date\">date</option>
> <option value=\"float\">float</option>
> <option value=\"int\">int</option>
> <option value=\"text\">text</option>
> <option value=\"varchar\">varchar</option>
> </select>
> </td>
>
> <td align=\"center\"><input type=\"text\"
> name=\"field_length[]\" size=\"5\"></td>
> ";
> }
>
> $form_block .= "<tr>
> <td align=\"center\" colspan=\"3\"><input type=\"submit\"
> value=\"Create Table\"></td>
> </tr>
> </table>
> </form>
> ";
> ?>
>
> <html>
> <head>
> <title>Create a Database Table: Step 2</title>
> </head>
> <body>
>
> <h1>Define fields for <?php echo "$table_name"; ?></h1>
> <?php echo "$form_block"; ?>
>
> </body>
> </html>
>
>
>
>
>
> Script #2
>
>
> <?php
>
> $db_name="testDB";
>
> $connection = @mysql_connect("localhost", "afghan", "office939") or
> die ("Couldn't connect.");
>
> $db = @mysql_select_db($db_name, $connection)
> or die("Couldn't select database.");
>
> $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 .= ")";
>
> $result = @mysql_query($sql,$connection) or die("Couldn't execute
query.");
>
> if ($result) {
> $msg = "<p>$table_name has been created!</p>";
> }
>
> ?>
>
> <html>
> <head>
> <title>Create a Database Table: Step 3</title>
> </head>
> <body>
>
> <h1>Adding table to <?php echo "$db_name"; ?>...</h1>
>
> <?php echo "$msg"; ?>
>
> </body>
> </html>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]