SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Hybrid View
-
Jun 5, 2007, 18:43 #1
- Join Date
- Aug 2004
- Location
- Austin, TX
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Problems with MySQL Connection Code
When I put the following code into my mysql_connect.php file I created, it is not generating any output but I am pretty sure that it is not connecting to the database properly either. Do any of you see any problems with this code? Any way to test if it was successful or not?
PHP Code:<?php
DEFINE ('DB_USER', 'myuser'); // Database username.
DEFINE ('DB_PASSWORD', 'mypassword'); // Database password.
DEFINE ('DB_HOST', 'localhost'); // Database hostname.
DEFINE ('DB_NAME', 'mydbname'); // Database name.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error());
@mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error());
?>
-
Jun 5, 2007, 19:22 #2
- Join Date
- Jan 2002
- Location
- Australia
- Posts
- 2,634
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
try removing all the error suppressors (@) to see what error messages you're getting. (Might need to turn display errors on in php.ini)
There is nothing in the code above that should produce any output if the connection was successful. You'll need to execute a query to do that.
-
Jun 5, 2007, 19:27 #3
- Join Date
- Aug 2004
- Location
- Austin, TX
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Actually I tried removing those and I didn't see anything. Something must be wrong with the other part of my script.
Is anyone willing to help me go through my code to see what the problem is? I am sure it must be something simple, but I cannot figure it out for the life of me.
-
Jun 5, 2007, 19:52 #4
- Join Date
- Aug 2004
- Location
- Austin, TX
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It wasn't working because of the escape_data(); function that I added. I will have to figure out another way to escape it.
-
Jun 5, 2007, 21:19 #5
- Join Date
- Jan 2002
- Location
- Australia
- Posts
- 2,634
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is anyone willing to help me go through my code to see what the problem is?It wasn't working because of the escape_data(); function that I added. I will have to figure out another way to escape it.
-
Jun 5, 2007, 21:25 #6
- Join Date
- Aug 2004
- Location
- Austin, TX
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Bookmarks