connect to mysql
Home
Welcome, Guest. Please login or register.
Did you miss your activation email?

 



donations help testmy.net pay for the very high cost to run the site. Any amount is greatly appreciated.
Click to read why...

  spcr
    
News : testmy.net 2010 is coming very soon... stay tuned for the next generation of testmy.net!  :headbang: November 21, 2009, 06:48:22 PM
testmy.net Broadband  |  Main Forum  |  HELP!  |  Topic: connect to mysql Advanced search

Recommended Tests

Click here to run a free Performance Scan   TIP: Test how fast your system is really running
   Free Performance Scan
Click here to run a Free PC Error Scan    TIP: Test how many system errors your PC has
   Free PC Error Scan


Note: The links above are sponsored links
  0 Members and 1 Guest are viewing this topic. « previous next »
Pages 1 Go Down
Author
Topic: connect to mysql  (Read 1688 times)
cbtshare
Jr. Member
*
Offline Offline

Posts: 21



View Profile
« on: December 04, 2008, 04:52:26 PM »

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\’t Work: ' . mysql_error() );

 // Tell User we are done.
 echo 'Code Inserted';
?>
</code>


ERROR:
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test_insert_sql.php on line 7

line 7 is... $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")

the password and username is right I also use mysl-front and it connects fine with it.

Help please..



Logged
mudmanc4
Ɠξξ₭ òƒ Ɠξξ₭z
Global Moderator
TMN Seasoned Veteran
*
Online Online

Gender: Male
Posts: 6531



View Profile WWW
« Reply #1 on: December 04, 2008, 07:38:12 PM »


That error looks like a new install without mysql support, you probably forgot to copy the mysql.dll to your php directory. No ?
Logged



Don't do what others say - listen to them, but do what you feel good doing. ~ Warren Buffet
cbtshare
Jr. Member
*
Offline Offline

Posts: 21



View Profile
« Reply #2 on: December 04, 2008, 08:11:04 PM »

wow never read that anywhere, where would I find the mysql.dll to copy(guessin in the mysql folder)..will try and get back to you.

Thanks
Logged
cbtshare
Jr. Member
*
Offline Offline

Posts: 21



View Profile
« Reply #3 on: December 04, 2008, 08:25:34 PM »

still didnt work,  undecided I keep getting error @ mysql_connect("server", "root", "paws") or die(mysql_error());
Logged
Swimmer
Vice Admin
TMN Seasoned Veteran
*
Offline Offline

Gender: Male
Posts: 6410



View Profile WWW
« Reply #4 on: December 04, 2008, 09:13:01 PM »

can you run this for us:

Code:
<?php
phpinfo
();
?>

Logged

cbtshare
Jr. Member
*
Offline Offline

Posts: 21



View Profile
« Reply #5 on: December 04, 2008, 09:28:44 PM »

here ya go

http://ontariowiz.com/test.php
Logged
Swimmer
Vice Admin
TMN Seasoned Veteran
*
Offline Offline

Gender: Male
Posts: 6410



View Profile WWW
« Reply #6 on: December 04, 2008, 09:44:00 PM »

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

Quote
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:\php\libmysql.dll ) into your Window's System folder (usually C:\Windows\System32\ although might be C:\WinNT\System\ 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.
Logged

cbtshare
Jr. Member
*
Offline Offline

Posts: 21



View Profile
« Reply #7 on: December 04, 2008, 10:05:08 PM »

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
Logged
Swimmer
Vice Admin
TMN Seasoned Veteran
*
Offline Offline

Gender: Male
Posts: 6410



View Profile WWW
« Reply #8 on: December 04, 2008, 10:06:49 PM »

Not a problem.. glad it worked!  I normally dont use Windows for website stuff.. So I learned something also.
Logged

Print  Pages 1 Go Up
testmy.net Broadband  |  Main Forum  |  HELP!  |  Topic: connect to mysql « previous next »
Jump to:  

    
testmy.net's forum is proudly Powered by SMF | SMF © 2006-2007, Simple Machines LLC
Bookmark: Del.icio.us    StumbleUpon
 
 

 

© 1999-2009 testmy.net - Contact - Legal - Facts & FAQs
Page Loading Stats: This forum Page created in 0.104 seconds with 41 queries.