Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14828
| From | Matthew Carter <m@ahungry.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: mysql_connect statement not connecting to database |
| Date | 2015-01-15 11:49 -0500 |
| Organization | Ahungry (http://ahungry.com) |
| Message-ID | <87oaq0yooh.fsf@ahungry.com> (permalink) |
| References | <66710953-7d91-407e-8589-b919c0adba6a@googlegroups.com> |
mcghepa@gmail.com writes:
> I am attempting to try and connect to my mysql database. I am using
> apache webserver. When I run a php script through localhost through
> my browser the script works well. When I run my mysql_connect.php
> then all I get is a blank page. nothing happens. I placed an echo
> statement at the end to verify that it connected. The echo statement
> doesn't appear when I refresh the page.
>
>
> <?php //# Script 7.2 - mysql_connect.php
>
> // This file contains the database access information. // This file
> also establishes a connection to MySQL and selects the database.
>
> // Set the database access information as constants. DEFINE
> ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', 'pass@word1'); DEFINE
> ('DB_HOST', 'localhost:3306'); DEFINE ('DB_NAME', 'reg');
>
> // Make the connnection. $dbc = @mysqli_connect(DB_HOST, DB_USER,
> DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
>
> // Select the database. @mysqli_select_db(DB_NAME) OR die ('Could not
> select the database: ' . mysql_error() );
>
> echo 'hello'; ?>
The '@' suppresses error output, try removing and see what you get.
Does the command line work with those credentials for connecting?
mysql -h localhost:3306 -u root -p'pass@word1'
If that does connect from the CLI, when you do a SHOW TABLES do you see
'reg' listed?
Could be a permissions error with your mysql user or incorrect info.
--
Matthew Carter (m@ahungry.com)
http://ahungry.com
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
mysql_connect statement not connecting to database mcghepa@gmail.com - 2015-01-15 08:21 -0800
Re: mysql_connect statement not connecting to database Matthew Carter <m@ahungry.com> - 2015-01-15 11:49 -0500
Re: mysql_connect statement not connecting to database Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-15 18:01 +0100
Re: mysql_connect statement not connecting to database Matthew Carter <m@ahungry.com> - 2015-01-15 14:43 -0500
Re: mysql_connect statement not connecting to database Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-17 15:48 +0100
Indent style (was: mysql_connect statement not connecting to database) "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-17 18:13 +0100
Re: Indent style Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-17 19:08 +0100
Re: Indent style "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-01-22 14:22 +0100
Re: mysql_connect statement not connecting to database richard <noreply@example.com> - 2015-01-16 00:10 -0500
Re: mysql_connect statement not connecting to database Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-16 10:03 +0000
csiph-web