scriptygoddess

01 Aug, 2002

mySQL call for help

Posted by: Jennifer In: Projects

Ok, I'm just about to go insane here. I'm working on a little mySQL project, and I can't even get as far as having the "application" (such as it is at all of just a few lines at the moment) to select the database.

I've connected to the database fine, but when it comes time to select a database, it dies. I've looked everywhere, but kind figure out why it would be happening.

Anyone run into this problem before? Have any suggestions? I've tried multiple varations on the following code:

$hostname = "localhost";
$username = "USERNAME";
$password = "PASSWORD";
$dbName = "USERNAME_DATABASENAME";

/* MySQL table created to store the data */
$userstable = "mytable";

/* make connection to database */
mysql_connect($hostname,$username,$password) OR DIE("Unable to connect to database");

/* please note, I've also tried pconnect, either way, it connects to mySQL just fine… it's the next line that dies out no matter what…. */

mysql_select_db($dbName) or die("Unable to select database");

I've also tried using the function: mysql_selectdb, I've tried having the reference to the db connection stored in a variable ($db) and then doing:
mysql_select_db($dbName, $db)
I've tried putting $dbName in qoutes, $db in quotes, putting an "@" symbol before mysql_connect or mysql_pconnect, or before mysql_select_db (I have no idea what the significance of the "@" symbol is…

AAaaaah! Going. Insane.

4 Responses to "mySQL call for help"

1 | k

August 1st, 2002 at 12:40 pm

Avatar

try this:

mysql_select_db($dbName) or die (mysql_error()) ;

That should give you the mysql error, and it might help. Also, the @ before a function supresses any error messages that might otherwise result. Also add the mysql_error() to the other mysql functions you use – it could be that the error is occuring before hand

2 | Jennifer

August 1st, 2002 at 1:16 pm

Avatar

Excellent! That does help a great deal. Apparently, it's a problem with the user… it's not giving that user access to the database (thought they had added that user to the database, but at least I know where to start looking to solve the problem).

Thank you!!!

3 | Jennifer

August 1st, 2002 at 7:55 pm

Avatar

Just putting this here for my future reference… to reset the auto-increment in a table, do this:
ALTER TABLE tbl_name AUTO_INCREMENT = 1;

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements