mysql_connect parameters
Posted by: t4newman (---.bb.sky.com)
Date: February 15, 2010 11:53PM

What is the correct parameter setting for a mysql_connect command for a default installation of wamp?

"host" = "locahost"
"
"user" = "root"

"password" = ""

Options: ReplyQuote
Re: mysql_connect parameters
Posted by: t4newman (---.bb.sky.com)
Date: February 16, 2010 12:09AM

This is what happens when I move from an HTML form to my PHP script:-

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\ccn\listprops.php on line 104
Could not connect: Access denied for user 'root'@'localhost' (using password: YES)

Options: ReplyQuote
Re: mysql_connect parameters
Posted by: yfastud (Moderator)
Date: February 16, 2010 12:10AM

you need to setup a db for it

to setup db, follow this
[blog.jlbn.net]

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides



Edited 1 time(s). Last edit at 02/16/2010 12:11AM by yfastud.

Options: ReplyQuote
Re: mysql_connect parameters
Posted by: t4newman (---.nhs.uk)
Date: February 16, 2010 10:40AM

Yes, I had created a db using phpadmin but my script just lists the php commands on-screen as if it's not even attempting a db connection.

Options: ReplyQuote
Re: mysql_connect parameters
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: February 16, 2010 11:05AM

maybe u have <? ?>

u need <?php ?>

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 02/16/2010 11:05AM by stevenmartin99.

Options: ReplyQuote
Re: mysql_connect parameters
Posted by: Briskold (---.static.vega-ua.net)
Date: February 23, 2010 04:43PM

Once you have created a database, there are a few ways you can connect to it.
To connect from a PHP script, just put this in your file:

<?
 
    mysql_connect("DBSERVER", "DBUSERNAME", "DBPASSWORD" ) ;
 
    mysql_select_db("DBNAME" ) ;
 
    ?>
using the following substitutions for the bold terms as above, plus substituting DBPASSWORD with your own mysql password:
Replace DBSERVER with the correct database servername for your site.
Replace DBUSERNAME with your own mysql username.
Replace DBNAME with your own mysql databasename.
The connection will be closed automatically when the script ends as i remember from php tutorials. To close the connection before, use the mysql_close() function:
 <?php
 
$con = mysql_connect("localhost","peter","abc123" ) ;
 
if (!$con)
 
  {
 
  die('Could not connect: ' . mysql_error());
 
  }
 
// some code
 
mysql_close 

Options: ReplyQuote


Sorry, only registered users may post in this forum.