Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications > Virtualization and Cloud Computing
google site



Virtualization and Cloud Computing Xen, VMWare, hypervisors, Amazon Elastic Computing Cloud, EC2, virtual storage, Amazon S3 and other cloud computing topics.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #1  
Old 12-06-2009
Registered User
 

Join Date: Dec 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Problems with PHP query to MySQL database

Hello all,
I completed a website (it was code by php) and putted it to AWS, I install fedora instance in EC2 with the base is php and mysql.
I putted all files of my website to folder /home/webuser/helloworld/htddocs and my database (mysql) to folder /var/lib/mysql/test ("test" is my database's name).
I connect to database by a php file that is successful and its code is:


Code:
<?php # mysql_connect.php 
DEFINE ('DB_USER', 'root'); 
DEFINE ('DB_PASSWORD', 'ab2345'); 
DEFINE ('DB_HOST', 'root@localhost'); 
DEFINE ('DB_NAME', 'test'); 
# Connect to MYSQL 
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MYSQL:' .mysql_error()); 
mysql_select_db (DB_NAME) OR die ('Could not select the database:' .mysql_error()); 
?>

I made query commands to my database in PuTTY succesful and had data at output

But when I make query commands to database in php files (code by php) then didn't output, it is nothing. I don't know why, I searched more it in Internet but I didn't still find, I hope you can help me.
Thanks,

Last edited by pludi; 12-07-2009 at 01:14 AM.. Reason: code tags, please...
Sponsored Links
  #2  
Old 12-07-2009
Neo's Avatar
Neo Neo is online now Forum Staff  
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 7,840
Thanks: 28
Thanked 43 Times in 21 Posts
What does the php.errors log file say about this?
  #3  
Old 12-20-2009
Registered User
 

Join Date: Nov 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Try change:

Code:
DEFINE('DB_HOST', 'root@localhost');

to

Code:
DEFINE('DB_HOST', 'localhost');

Got this error when trying your code:
Quote:
Could not connect to MYSQL:Unknown MySQL server host 'root@localhost' (1)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
NetHawk Cuts its Database Costs by 50% with Sun’s Embedded MySQL database Linux Bot MySQL DevZone RSS 0 09-16-2009 10:15 PM
Developing MySQL Database Applications With PHP Part 1: Using the MySQL Improved Exte Linux Bot Solaris BigAdmin RSS 0 06-12-2009 06:00 PM
MySQL Developer, meet “Quan” (aka the MySQL Query Analyzer) Linux Bot MySQL DevZone RSS 0 05-15-2009 01:30 PM
New MySQL Enterprise with Query Analyzer Boosts Database Application Performance Linux Bot MySQL DevZone RSS 0 11-19-2008 03:10 AM
How to query one to many mysql pinkgladiator Programming 0 10-30-2008 12:45 PM



All times are GMT -4. The time now is 11:50 PM.