Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14828
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Matthew Carter <m@ahungry.com> |
| Newsgroups | comp.lang.php |
| Subject | Re: mysql_connect statement not connecting to database |
| Date | Thu, 15 Jan 2015 11:49:18 -0500 |
| Organization | Ahungry (http://ahungry.com) |
| Lines | 41 |
| Message-ID | <87oaq0yooh.fsf@ahungry.com> (permalink) |
| References | <66710953-7d91-407e-8589-b919c0adba6a@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="7c986cd4736462de309a749b207746fe"; logging-data="25308"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MTdUH00bClrCJ2RkA0fUg" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| Cancel-Lock | sha1:OmzvCfypRfo5Gt4aSl5du2kzh7Y= sha1:qT9ozSHiX/OB2liPNqUXzd0NUzw= |
| Xref | csiph.com comp.lang.php:14828 |
Show key headers only | View raw
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