First off, the line of code where he has this is wrong::
if (mysql_create_db ($DName, $Link)) {
it should have DBName, not DName. That could be a big issue when executing.
Second, I have no expirience with PHP but am great with ASP and believe that
the term 'echo' would work better than 'print'. I dont know why other than
I've never seen 'print' used in PHP other than right hre and 'echo' I've
seen in the PHP manual and some books to write text. I mostly think it's
the first thing that I said.
- Deryck H
- http://www.comp-u-exchange.com
----- Original Message -----
From: "Paul DuBois" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, September 15, 2001 8:26 AM
Subject: Re: PHP and SQL
> At 4:50 PM +1000 9/15/01, mike wrote:
> >I am new to both PHP and MySQL (I have experience in ASP) and am trying
> >to get my server running both. I can connect to the MySQL server under
> >DOS using the command line and can create new databases this way. I want
> >to create a web data site so I need to accomplish this via HTML. I have
> >tried to follow the instruction in various books without success. Can
> >anyone help with advice?
> >
> >Below is the simple code I am using that the book tells me should work
> >but it doesn't.
>
> Try printing the results of mysql_error($Link) and mysql_errno($Link)
> to see what the problem is. Or are you getting a syntax error, or what?
> You don't mention what actually happens, other than "doesn't work."
>
> The script will of course fail if the database already exists.
>
> >
> ><HTML>
> ><HEAD>
> ><TITLE>Creating a Database</TITLE>
> ></HEAD>
> ><BODY>
> ><?php
> >// Set the variables for the database access:
> >$Host = "localhost";
> >$User = "root";
> >//$Password = ""; (no password set at this stage)
> >$DBName = "testbase2";
> >
> >$Link = mysql_connect ($Host, $User);
> >if (mysql_create_db ($DName, $Link)) {
> > print ("The database, $DBName, was successfully
> >created!<BR>\n");
> >} else {
> > print ("The database, $DBName, could not be created!<BR>\n");
> >}
> >mysql_close ($Link);
> >?>
> ></BODY>
> ></HTML>
> >
> >TIA
> >
> >Mike
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >Before posting, please check:
> > http://www.mysql.com/manual.php (the manual)
> > http://lists.mysql.com/ (the list archive)
> >
> >To request this thread, e-mail <[EMAIL PROTECTED]>
> >To unsubscribe, e-mail <[EMAIL PROTECTED]>
> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
> --
> Paul DuBois, [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php