Jump to content

[SOLVED] PHP not recognizing MySQL?


Treval

Recommended Posts

 

Ok guys what are the steps I have to do in order to setup MySQL with PHP?

 

I read on here that you guys set values in php.ini and I don't think I did that.

I got Apache running too and I'm on Wnidows XP Pro.

I probably have to add lines to httpd.conf concerning MySQL?

 

Which could explain why all my PHP scripts that try to connect to MySQL are displaying a blank page..

I don't know the reason yet.

I used default codes from google to connect.

 

Here's one:

 

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');

$dbname = 'petstore';
mysql_select_db($dbname);
?> 

 

Any help is greatly appreciated.

 

Treval

 

 

 

 

Link to comment
Share on other sites

Yes please read the Sticky titled Call to undefined function mysql_connect() in the PHP Help forum or the PHP Installation forum.

 

Also it is recommended to set error_reporting to E_ALL in the php.ini whilst you are learning/developing your scripts. Before you change it make sure that display_errors is set to On in the php.ini too. That way if any errors crop up it will show you errors as to why rather than getting an unhelpful blank page.

 

Also any changes you make to the php.ini make sure you save it and restart Apache.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.