PHP to Mysql Problem
hi guys, please help me out on this issue.
i had this code to connect to mysql using php but there is no any message displayed.
nothing is displayed on the screen, whether the connection is successful or there is an error.
any ideas?
i can connect to mysql using command prompt without a problem, but through this code below nothing is displayed on the screen.
any help is greatly appreciated.
<html>
<body>
<?php
$link = mysql_connect('localhost', 'my_username', 'my_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
</body>
</html>
cguan_77
Nearly a Posting Virtuoso
1,361 posts since Apr 2007
Reputation Points: 19
Solved Threads: 117
Skill Endorsements: 0
Selecting the database is optional, not required. Anyway, check your error log, to see if perhaps the mysql extension is not installed, or perhaps some other configuration errors. The code the OP provided is correct.
pritaeas
Posting Prodigy
9,534 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98
hi guys, thanks for your replies.
there's nothing on the error log as well, I was hoping that there would be an error so there's something i could start with but i got no clue.
i'm just starting on this please bear with me, the extension we're talking about is it
the extension_dir on php.ini?
if that's the extension_dir on php.ini, i had set that one already.
i had checked the php info, i could see that mysql is loaded.
i'm really stucked, any ideas? thanks :)
cguan_77
Nearly a Posting Virtuoso
1,361 posts since Apr 2007
Reputation Points: 19
Solved Threads: 117
Skill Endorsements: 0
any ideas?
Sorry. The code is fine, so it has to be a configuration thing, but that's difficult to guess.
pritaeas
Posting Prodigy
9,534 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98
hi guys, thanks for all your help.
i had installed WAMP and it works fine.
it's a bit troublesome installing the package one by one.
installing WAMP does everything. :) thanks again..
cguan_77
Nearly a Posting Virtuoso
1,361 posts since Apr 2007
Reputation Points: 19
Solved Threads: 117
Skill Endorsements: 0
Question Answered as of 9 Months Ago by
pritaeas,
xjshiya,
vaayaa1
and 1 other