Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

PHP and MySQL not communicating

General Tech Bugs & Fixes

Max. 2000 characters
Replies

usr_profile.png

User

( 5 months ago )

I have come to the conclusion that my PHP installation and my MySQL installation are not getting along; I’m working on making my first web page that uses MySQL for content, but after two days, man pages, online documentation, and dozens of tutorials, I just can’t get the PHP/MySQL part to work. I have an established home web server (I am the only admin/user) that runs Apache and hosts my web pages. I have MySQL installed, and was able to create and query a database through Terminal. I have PHP installed, and can use echo to print text to the document. When I work with MySQL however, everything changes…

I have a page that contains initialization stuff in . contains a few paragraphs of hardcoded HTML and then PHP code to access MySQL. When I first loaded the page, all that resulted was a blank page. I commented out the PHP section and reloaded to confirm that the plain HTML still worked, which it did. Therefore, some part of PHP was keeping any of the page from ever loading.

To begin troubleshooting my code, I left all of the PHP code commented except the following code for the server connection, which is adapted from several different tutorials:

<?
echo("<p>PHP is working</p>"); 
$ses = mysql_connect("localhost","username","password");
if(!$ses){
 echo("<p>Connection to content server failed.</p>");
 exit();
}
echo("<p>Database Connected</p>");
?>

When the page is loaded, the beginning HTML loads in addition to a paragraph reading “PHP is working” but neither the failure or success message appear. I removed the If structure from the code - so that only two echos and the mysql_connect remained – and got the same result.

It seems that the mysql_connect feature is causing the server to stop loading the code when it is run, but I’m out of ideas for how to fix it. For the record: I’ve modified the php.ini file to include the “connection = msql.so” line, and I’m using MySQL 5.5, Apache 2.2.22, PHP 5.3.10, Ubuntu 12.04. Also, both my router and modem have been configured to forward port 3306 to the server – though I don’t see how that should be necessary – and my MySQL username and password have been triple checked and are identical to the ones that I use successfully in Terminal.

What am I missing?

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif