473,326 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

php to mysql connection

3
Hi all,
I am a WAMP newbie and would appreciate your help! I have installed Apache 2.2.4, Mysql 5 and PHP 5 have got them all up and running and tested them separately, I was able to do the info.php test to display environment variables in a browser successfully. I tried to test a connection to mysql using the following code:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>mysql connection test</title>
  4. </head>
  5. <body>
  6. <h2>
  7. <p>Testing now!</p>
  8. <?php
  9. $dbhost = 'localhost';
  10. $dbuser = '**********';
  11. $dbpass = '**********';
  12.  
  13. $connection = mysql_connect($dbhost, $dbuser, $dbpass)
  14. or die ("Sorry  - unable to connect" . mysql_error());
  15.  
  16. echo ("Congrats - connection established");
  17. ?>
  18. </h2>
  19. </body>
  20. </html>
  21.  
[Please use CODE tags when posting source code. Thanks! --pbmods]

which is I understand is fairly standard code to test a connection with (the **** fields actually contain my username and password :)

When i run this through a browser all I get returned is the "Testing now!" from the html - no errors - nothing!

I do have error reporting turned on in the php.ini file (error_reporting = E_ALL & ~E_NOTICE)
Any ideas people??

thanks,
obmij
May 26 '07 #1
4 2091
pbmods
5,821 Expert 4TB
Heya, obmij. Welcome to TSDN!

I do have error reporting turned on in the php.ini file (error_reporting = E_ALL & ~E_NOTICE)
You have error reporting turned on... but where do the errors get reported? Do you have display_errors turned on, or is it writing them to your server's error log?

Also, check the source of the page you're loading. Is your PHP code getting parsed, or is it just getting output? If your code is in a .html file, try changing the extension to .php instead.
May 26 '07 #2
obmij
3
Heya, obmij. Welcome to TSDN!



You have error reporting turned on... but where do the errors get reported? Do you have display_errors turned on, or is it writing them to your server's error log?

Also, check the source of the page you're loading. Is your PHP code getting parsed, or is it just getting output? If your code is in a .html file, try changing the extension to .php instead.

Thanks for such a speedy reply!
display_errors was off so i have uncommented that line. Now when i run the above file (which is a .php file) i get the following error:

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

which would seem to indicate that php cannot find the mysql function even though i have uncommented the "php_mysql.dll" extension in the php.ini file.
I have also edited the "extension_dir" variable in the php.ini file to read:
extension_dir = "C:\Program Files\PHP"
Curiously when I run the phpinfo() file it still reports the "extension_dir" as being C:\php5 (and the php.ini path as being C:\windows) - which they definitely are not!

I have been reading around these problems - they seem to be quite common for WAMP installations but a lot of the solutions seem to contradict one another.
I am thoroughly confused!!
May 26 '07 #3
Motoma
3,237 Expert 2GB
I would suggest using one of the various packaged installers for Apache, MySQL, PHP on the windows platform. WAMP5 and Netserver come with my strong recommendation.
May 26 '07 #4
obmij
3
I would suggest using one of the various packaged installers for Apache, MySQL, PHP on the windows platform. WAMP5 and Netserver come with my strong recommendation.

Thanks for the advice - I downloaded WAMP5 and it works just fine!
May 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Robert Mazur | last post by:
MySQL 5.0 alpha (binary install) on Solaris 9 -or- RedHat 8.0 mysql-connector-java-3.0.8-stable ----------------------- Is there something different going on with JDBC and the alpha version...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
1
by: zMisc | last post by:
I am looking at using MySQL in my application (currently works with Access and SQL Server 2000). Is it possible to access MySQL database using ADO? What is the connection string for this? ...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
7
by: Ike | last post by:
Let's say I have a MySQL 4.12 database, opened to the internet on 111.111.111.111 allowing all incoming and outgoing ports. I have a username and password setup, which CAN connect to this database,...
5
oll3i
by: oll3i | last post by:
my librarybean package library.ejb; import java.sql.*; import javax.ejb.*; import library.common.*; @Stateless @Remote
3
by: tulika dutta | last post by:
after 8 hrs my MySQL connection with JDBC gets time out. It gives the error java.sql.SQLException: No operations allowed after connection closed.Connection was implicitly closed due to underlying...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.