Jump to content

Very simple SQL usage


Cykon

Recommended Posts

I recently decided to take php under my belt after having background knowledge from a few other coding languages.

 

I am currently toying around with SQL queries and such.

 

-My Apache server is working

-PHP is installed and working

-I can access my MySQL server via Navicat

 

Now no matter what I do, I can not get the php script to use an SQL command, I have tried quite a few different sample scripts, this one being the newest (From one of the documentations on mysql commands for PHP)

 

<?php
$host = "takenout";
$username = "takenout";
$password = "takenout";
$link = mysql_connect($host,$username,$password);
if (!$link) 
{
    	die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

 

It does not output either messages when I go to the test page, but if I add a simple text line with echo at the top, it will output that specific message

 

Now I have a strong feeling that the problem does not lie in this (or the other) code(s)... but if "other" php commands work... my apache server works... and I know for sure my mysql server is up... what is the problem!

 

Thanks!

Link to comment
Share on other sites

The php mysql language extension is not enabled.

 

A) You should set error_reporting to E_ALL and display_errors to ON in your php.ini to get php to help you. Stop and start your web server to get any change made to php.ini to take effect and check using a phpinfo(); statement that the settings were actually changed. The is likely a fatal runtime error concerning non-existent mysql_xxxxx functions. You will save a large amount of time learning php, developing any php code, and debugging any php code with these two settings set as indicated.

B) There are instructions posted all over on how to enable the mysql extension. If php is installed correctly, you should only need to uncomment the extension=php_mysql.dll line in the correct master php.ini and stop and start your web server.

Link to comment
Share on other sites

Thanks for the response, I had the first two things already in, but the third I had to enable...

 

I assume I move php_mysql.dll into my system32 folder?

 

Well... I tried it restarted my server and now it crashes when I try to run a mysql command >.<*

 

(before it was giving a command not found error)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.