Problems with PHP query to MySQL database

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Virtualization and Cloud Computing Problems with PHP query to MySQL database
# 1  
Old 12-06-2009
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 02:14 AM.. Reason: code tags, please...
# 2  
Old 12-07-2009
What does the php.errors log file say about this?
# 3  
Old 12-20-2009
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)
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Programming

Need help in mysql query

Hi All, i have a table in mysql with the following data Table name Test Assettype Serial_No Status location Mouse 123456 In Stock chennai Mouse 98765 Allocated chennai Keyboard ... (2 Replies)
Discussion started by: venkitesh
2 Replies

2. Linux

PHP is not execute the query from mysql in Linux

Hi , I have ran the php script from Linux box. It is running, But I can able to see any html content. There is no mysql data on that page. I have checked . 1) Mysql and data bases are connected successfully. Please help and guild me If I missed any think during the configuration. ... (13 Replies)
Discussion started by: Mani_apr08
13 Replies

3. Web Development

mysql query help

hello all i have 2 columns every column in the following format column1 2011-04-01 11:39:54 column2 2019-02-03 00:00:00 i want get difference between above data as following 2 days 11:39 how to do so ? i tried many functions but nothing works please advice what is the query... (6 Replies)
Discussion started by: mogabr
6 Replies

4. Programming

How to query one to many mysql

Hi there, I have a hierarchical database that include 4 tables. Table A is the parent of B, B is Parent of C, C is parent of D. If I want to query everything in D that is associated with A.name, how do I do that? Thanks! YanYan (0 Replies)
Discussion started by: pinkgladiator
0 Replies
Login or Register to Ask a Question