connect to mysql with php - correction
Derick Centeno
aguilarojo at verizon.net
Fri Jan 19 08:44:08 MST 2007
Hi Pat:
Here are some links addressing your question which may help:
1. http://www.php-mysql-tutorial.com/connect-to-mysql-using-php.php
2. http://php.about.com/od/phpwithmysql/qt/mysql_connect.htm
3. http://www.siteground.com/tutorials/php-mysql/php_mysql_connection.htm
According to link 1, you may have left out an "n" and it may be a good
idea to follow the example and have an error statement embedded
reminding you when something breaks. A password to access the db is
dependent on whether it's use is just for yourself or a db you'll share
with others. Generally, using passwords is a good idea as a means of
protecting the value of the information in your db.
Applying the example in link 1 to your code the correction could be:
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('Error
connecting to
mysql');
I said the above could be useful because if you've given your system a
name, the above won't work. When you built your Linux system during the
installation process you were asked how your system would be named.
Of course, many leave that name alone and so it remains the generic
label we see here called "localhost".
The better idea is to give it a name. Let's say we call it excaliber.
Then the above instructions change to:
<?php
$dbhost = 'excaliber';
Good Luck ... Derick.
------------------------------------------------------------------------
Pat kilgore wrote:
> I have YDL 5.0 installed on an iBook installed as a server with
> apache, php, and mysql selected as installed services.
> MySQL is running and from command line I have created database, table
> and data.
> Problem is connecting to mysql with php.
> The line
> $con = mysql_connect("localhost","root");
> in php page breaks the script and nothing after this line will execute.
> php functions run ok.
>
> Pat
>
> _________________________________________________________________
> Type your favorite song. Get a customized station. Try MSN Radio
> powered by Pandora. http://radio.msn.com/?icid=T002MSN03A07001
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> yellowdog-newbie mailing list
> yellowdog-newbie at lists.terrasoftsolutions.com
> http://lists.terrasoftsolutions.com/mailman/listinfo/yellowdog-newbie
>
_______________________________________________
yellowdog-newbie mailing list
yellowdog-newbie at lists.terrasoftsolutions.com
http://lists.terrasoftsolutions.com/mailman/listinfo/yellowdog-newbie
More information about the yellowdog-newbie
mailing list