View Full Version : problem MySql-PHP
Hi there I'm runing Windows 2000 SP 3, I have the MySql ver 3.23.52 and the PHP 4.2.3 CGI version.
I'm havin' problems with it, suddenlly it stops runing, I don't know why, but it stops working only php, if I make a query from MySql Client it works like a charm, but I just cant connect from php, (in fact that's the error I Get ) the problem solution, or unless how I correct it, is to restart my server, but it's a little caveman-one I guess.
Shoul I get the latest version of php and MySql, or just php or just MySql???
Any help will b usefull.
Thnx
What server are you running? Does mySql keep running after you have problems with php? Does php keep working for other things?
A lot of questions, but they might help the diagnosis. If I've understood your post properly, it sounds as if php is falling over. This could either be the php engine itself, or the server.
I'm Using Win2k and IIS.
Yes, MySql keeps running; and PHP to, it takes me to the page I create when I can not connect, so it works like a charm but without connection with MySql, so no DataBase :(
krycek
12-20-2002, 01:29 AM
I would say, first check your setup by using a 3rd party script like phpMyAdmin. If that works, it is your own script at fault... post the part that deals with connecting to the database and we'll help you out :) Otherwise if phpMyAdmin doesn't work (assuming you configured it correctly) it should at least give you an error - come to that, if you have setup PHP and MySQL correctly (not too hard to do) and you are using the correct methods in your scripts, you should have some form of useful error message.
Hope that helps!
::] krycek [::
the code I use to connect is :
<?php
$dbcnx = @mysql_connect("localhost", "guest");
if(!$dbcnx)
{
echo("<p>No se pudo enlazar a la base de datos: " . mysql_error() . "</p>");
exit();
}
else
{
// the code of my page
}
?>
the thing is that I don't know where is the phpMyAdmin, and about the configuration, I guess is correct, I installed it with the "setup.exe" vesion, I mean it configurates it self I think.
I don't know how tio make the test you ask me to do, please explain.
Thanx
krycek
12-20-2002, 02:32 PM
well, firstly have you set up an account "guest"?
Normally you connect with your password as "" and your username as "root"... until you change it, that it the default.
Also you will have to specify a database to connect to once you are in.
For example:
function dbconnect($host = "localhost", $username = "root", $password = "", $dbname = "") {
// Connect to MySQL
if (!@mysql_connect($host, $username, $password)) return false;
// Select database
if (!empty($dbname) && !@mysql_select_db($dbname)) return false;
// Success!
return true;
}
That is a very simple function which is a compacted version of my own connection function. It will return true if it connects ok.
To use it:
$connected = dbconnect();
Then, check the value of $connected.
Note that you will have to pass through the necessary variables to the function, i.e. your database name for a start, in order to get very far. But it should give you an idea.
Oh, and about phpMyAdmin, it is a 3rd-party script for database admin, very good and used everywhere. Search for it on Google.
::] krycek [::
another useful call is to put
echo mysql_error();
after the db access/update scripting to determine what is going wrong at mysqls end.
krycek
12-20-2002, 05:07 PM
heheh very true :thumbsup: I handle all my errors in separate routines so I forgot to stick any error stuff in the code I posted lol :)
::] krycek [::
I already have configurated a guest acount in MySql, and I use two diferent DB that's why I didn't put it in the code, since I change db several times in a script, could it that be the very problem?
Also, I acces the same Db from another aplication (a C++ DirectX8.1) and that one keeps working fine, should I lock tables? or some thing? to prevent conflicts?
by the way do u know how to make an ODBC connection with MySql? I want to use Microsoft Excel to view some tables.
Thanx
Any Ideas?, please answer...
krycek
12-24-2002, 04:22 AM
I don't know anything about using C++ with MySQL, nor do I know about ODBC with MySQL. I am not even sure if it can do it. Look in the manual?
However, you should not have to lock tables or anything, as MySQL does that automatically every time there is a query, from whatever source.
I suggest again that you download and configure phpMyAdmin, if it works then your script is wrong :)
::] krycek [::
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.