Jump to content
cbtshare

connect to mysql

Recommended Posts

Hey sup,

            I have installed apache 2.2 on windows and mysql as well.I created a database and also a function , but I cant seem to connect to the database via the browser.(I installed php on apache as well)this is what I have and the error i'm getting.

<code>

<?php

// Connect to the database

$dbhost = 'localhost';

$dbusername = 'root';

$dbpasswd = '***';

$database_name = 'simple';

$connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")

  or die ('Couldn't connect to server.');

$db = mysql_select_db("$database_name", $connection)

  or die('Couldn't select database.');

// Generate SQL code to store data on database.

$insert_sql = 'INSERT INTO simple_table (text) VALUES ('test text, 1,2,3')';

// Execute SQL code.

mysql_query( $insert_sql )

  or die ( 'It Didn

Share this post


Link to post
Share on other sites

good.. you got php installed correctly..  php5 doesnt not include mysql support..

Unfortunately PHP5 removed built-in support for MySQL. To get it to work, the easiest way is to copy the mysql library file by hand. Open the folder you unzipped your PHP to. Copy the libmysql.dll file (should be located like C:phplibmysql.dll ) into your Window's System folder (usually C:WindowsSystem32 although might be C:WinNTSystem or something).

Then open up your php.ini in a text editor and search for ;extension=php_mysql.dll and remove the ; infont of that line.

Restart Apache and see if you get any errors. If it complains about "php_mysql.dll" either your extension directory isn't correct or windows can't find libmysql.dll

That should fix the issue.  System32 is the best bet.. as it is already in the Windows PATH variable.

Share this post


Link to post
Share on other sites

thak you very very much IT guru swimmer!! it worked.

**little note**

when installing php you have to copy the php.ini file into windows system32 as well, but dont edit that one.Edit the one in your php folder...(Just incase anyone else has this issue.)

Thanks ALOT Everyone

Share this post


Link to post
Share on other sites

×
×
  • Create New...