PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 8th, 2013, 10:17 PM
cteagle5 cteagle5 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 cteagle5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 18 sec
Reputation Power: 0
PHP-DB - Php not recognizing mysqli_connect

Hello,

I'm having a frustrating time trying to find out why php is not connecting to MySQL. Here's what I did;

* installed Apache Web server on a laptop. This is up and running.

* Installed php on the laptop and this is running and configured to Apache. I can bring up a dev website running php.

* installed MySQL database and created tables.

Now I'm trying to connect php to the database and php does not seem to be recognizing mysqli_connect.

I have the following within a php file.

<?php
$link = mysql_connect('localhost', 'root', 'password');
?>

If I view the source code after the page comes up it seems as if the webpage hits this piece of code and stops creating the rest of the page.

Any ideas;

You help is appreciated.

Reply With Quote
  #2  
Old February 8th, 2013, 10:58 PM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,843 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 7 h 18 m 54 sec
Reputation Power: 813
Hi,

are you talking about mysqli_connect (with an "i") or mysql_connect? Those are two completely different extensions. The first one is the current PHP extension for MySQL, the last one is obsolete.

In any case:

Turn on your error messages with
PHP Code:
 error_reporting(-1); 

or in the php.ini

And then check the exact error message. Maybe you don't have the extension activated.

Reply With Quote
  #3  
Old February 9th, 2013, 06:31 AM
cteagle5 cteagle5 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 cteagle5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 18 sec
Reputation Power: 0
update

I tried both mysqli_connect and mysql_connect. The error_reporting in the php.ini file was set tol

error_reporting = E_ALL;

I tried setting it to

error_reporting(-1);

However after I did that I stopped and tried to start apache. Apache wouldn't start as it couldn't parse error_reporting(-1); I do suspect as you indicate though that the mysqli_connect is not being recognized. How do I fix that?

Reply With Quote
  #4  
Old February 9th, 2013, 09:25 AM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,931 E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 7 h 43 m 47 sec
Reputation Power: 6991
In your php.ini file, look for the extension line that enables the mysql or mysqli extensions and uncomment it (if it's commented out). I don't recall exactly what it looks like, but it will say something like "extension=mysqli.dll".

Setting error_reporting alone isn't always enough to see error messages. You also need to enable display_errors. Entry #30 in the FAQ goes into depth on how to do this.

The error_reporting(-1) syntax would be something you would use in your actual php file, rather than in your php.ini file.
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #5  
Old February 9th, 2013, 09:37 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,843 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 7 h 18 m 54 sec
Reputation Power: 813
Quote:
Originally Posted by cteagle5
error_reporting = E_ALL;

I tried setting it to

error_reporting(-1);


No, check the syntax of the default configuration. It's
Code:
error_reporting = -1




Quote:
Originally Posted by cteagle5
I do suspect as you indicate though that the mysqli_connect is not being recognized. How do I fix that?


http://www.php.net/manual/en/mysqli.installation.php

But before you change anything, check the actual error.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-DB - Php not recognizing mysqli_connect

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap