Jump to content

[SOLVED] can't connect, no error message.


sebastiaandraaisma

Recommended Posts

Hi my name is Sebastiaan and I'm new to php, MySQL and Appache :)

I wrote some simple php scripts to test and help me forward in learning the language, but now I'm at a point where I'm stuck.

I will try to describe my problem.
I can't connect to the database trough php, I have a simple out of the book connection script that should show me an error message when I can not connect.
I do not receive any error message. In the php.info I have the following settings:
error_reporting E_All
Display_errors = off (I also tried the script with this function on)
Display_startup_errors = off (also this one I tried with both on and off)

When I try to use the script in both IE and Firefox I see an empty screen.

The MySQL command line client works. I can see databases and tables and add data.

My laptop is a XP 2002 Intel P. 1,86Ghz 504Mb ram

The MySQL status says:
Ver 14.12 Distrib 5.0.22, for win32 (ia32)
Connection ID 2
Current database (shows empty)
Current user root@localhost (I'm running off-line)
SSL Not in use
Using delimiter ;
Server version 5.0.22-community-nt
Protocol version 10
Connection localhost via TCP/IP
Characterset latin1
TCP port 3306

I have attached the php file where the data is written.

I hope some one knows what my problem could be? :)
I personally think its a setting somewhere but I'm to new to all of this to see where.

Any help is apriciated!

Kind regards,
Sebastiaan

[attachment deleted by admin]
Link to comment
Share on other sites

The reason is because you have the display_errors directive turned off in the php.ini. Turn this setting on.

When you turn it on, you must save the php.ini and restart the server for the new php.ini changes to come into effect. If you dont restart the server the new settings will not be loaded.

If you have done this, then confirm PHP is using the correct php.ini. You can do this by creating a new script (call it info.pphp) and add the following code to it:
[code=php:0]<?php phpinfo(); ?>[/code]
Now load this file up and look for the following line:
[b]Configuration File (php.ini) Path[/b]
To the right of that it should state the full path to the php.ini file PHP is using, is this the correct path to the php.ini you are editing?
Link to comment
Share on other sites

Thank you for your advise.
I did turned this setting on, but because I did not restarted the server I guess it didn't help :)

I will do the same and restart the server this time.
I don't know the path out of my head as I'm right now in an internet cafe, but I'm using the default path and used the "recommended php.ini" that came with the instalation.

Thank you for taking the time to answer.

Kind regards,
Sebastiaan
Link to comment
Share on other sites

I have turned the setting on, saved the php.ini and re-started the server.
This time I did get an error, indicating that I am working on the right php.ini file.

The error I got was:
Fatal error: Call to undefined function mysqli_connect() in C:\www.globalhome.eu\indextest.php on line 4
This is the text on line 4:
$mysqli = mysqli_connect("localhost", "joeuser", "somepass", "testDB");

I replaced mysqli_connect with mysql_connect but this gave the same error message.

I did expect to read the error "Connect failed" as the script I'm using says
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();

Any thoughts on this?

Kind regards,
Sebastiaan
Link to comment
Share on other sites

You will need to enable the mysqli extension if you wish to use the mysqli library. I have a thread setup in the FAQ board [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]here[/url] - that should help you

NOTE: That FAQ is setup to enable the standard mysql library, if you want to use the mysqli library then enable the php_mysqli.dll extension in stead.
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.