nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Getting PHP to access Mysql

This is a discussion on Getting PHP to access Mysql within the Databases servers forums, part of the Mastering Servers category; I am having problems accessing Mysql with PHP on Fedora Core 4. My code is one that I copied to ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Mastering Servers > Databases servers

Linux answers from nixCraft.


Databases servers Discussions of databases of all types - especially MySQL.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-20-2009, 05:10 AM
Junior Member
User
 
Join Date: Jan 2009
OS: Fedora Core 4
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ngalye is on a distinguished road
Question Getting PHP to access Mysql

I am having problems accessing Mysql with PHP on Fedora Core 4. My code is one that I copied to suit my case from Hard Coder as follows:
<?
$dbhost="localhost";
$dbuser="root";
$dbpassrd="adminpass";
$dbname="guestbk_db";
$dbconnect=mysql_connect($dbhost, $dbuser, $dbpassrd) or die("Error Connecting the Database Server!");
mysql_select_db($dbname, $dbconnect) or die("Error Selecting the Database!");
?>

When I try to load the pages I get the error as defined on die() above.

Any better way I can get it fixed. I googled some sites which hinted on installing php-mysql rpm. I did that but it went on asking for more files. I am using Fedora Core 4. I checked my installation on Webserver and Database Server, everything is installed. So where can be the problem? What do I do?

Ngalye
(newbie Linux newbie)
Reply With Quote
  #2 (permalink)  
Old 03-20-2009, 01:40 PM
amitabh's Avatar
Contributors
User
 
Join Date: Jul 2008
Location: New Delhi
OS: FreeBSD
Posts: 98
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Power: 4
amitabh has a spectacular aura about amitabh has a spectacular aura about amitabh has a spectacular aura about
Send a message via MSN to amitabh Send a message via Yahoo to amitabh Send a message via Skype™ to amitabh
Default

What does your phpinfo() command says? Do you have the proper mysql libraries loaded?

In a new file on your web server, type the following:
Code:
<?php
phpinfo();
?>
Open the file within your browser. It shows all the loaded modules/extensions within PHP. Check for any mysql related extensions.
Reply With Quote
  #3 (permalink)  
Old 03-20-2009, 07:24 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,695
Thanks: 11
Thanked 243 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Use yum command to install php and related dependencies.
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #4 (permalink)  
Old 03-23-2009, 05:11 AM
Junior Member
User
 
Join Date: Jan 2009
OS: Fedora Core 4
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ngalye is on a distinguished road
Smile Here extract from phpinfo() page

Quote:
Originally Posted by amitabh View Post
What does your phpinfo() command says? Do you have the proper mysql libraries loaded?

In a new file on your web server, type the following:
Code:
<?php
phpinfo();
?>
Open the file within your browser. It shows all the loaded modules/extensions within PHP. Check for any mysql related extensions.
Thank you Amitabh,

For the code above, I got the PHP info page loaded. Here's the extract from Mysql support table. I copied everything for your expert eyes to figure out if there's something missing.



mysql

MySQL SupportenabledActive Persistent Links 0 Active Links 0 Client API version 4.1.11 MYSQL_MODULE_TYPE external MYSQL_SOCKET /var/lib/mysql/mysql.sock MYSQL_INCLUDE -I/usr/include/mysql MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient
DirectiveLocal ValueMaster Valuemysql.allow_persistentOnOnmysql.connect_timeo ut6060mysql.default_hostno valueno valuemysql.default_passwordno valueno valuemysql.default_portno valueno valuemysql.default_socketno valueno valuemysql.default_userno valueno valuemysql.max_linksUnlimitedUnlimitedmysql.max_persist entUnlimitedUnlimitedmysql.trace_modeOffOff

mysqli

MysqlI SupportenabledClient API version 4.1.11 MYSQLI_SOCKET /var/lib/mysql/mysql.sock


DirectiveLocal ValueMaster Valuemysqli.default_hostno valueno valuemysqli.default_port33063306mysqli.default_pwno valueno valuemysqli.default_socketno valueno valuemysqli.default_userno valueno valuemysqli.max_linksUnlimitedUnlimitedmysqli.reconnect OffOff

Is it that I did not specify port number on my code?

Over to you again,...

Noel.
Reply With Quote
Reply

Tags
lamp , linux , mysql , php , php-mysql , rpm , yum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
repository access myfoot Web servers 1 03-13-2009 01:01 PM
FTP Access Through Proxy asifzias Networking, Firewalls and Security 2 01-31-2008 10:01 AM
MySQL remote server access howto raj Databases servers 0 07-29-2007 05:32 AM
Remote CVS Access rajuk Linux software 4 10-20-2006 10:41 AM
Debian recovery mode read only access make it write access Donavit Linux software 1 12-30-2005 12:49 AM


All times are GMT +5.5. The time now is 10:03 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38