mysql_connect doesn't work though phpmyadmin works

Problems with the Windows version of XAMPP, questions, comments, and anything related.

mysql_connect doesn't work though phpmyadmin works

Postby covenant » 11. June 2004 10:59

Hey there,

i'm a newby in xampp and mysql aswell. i installed xampp on my xp pro machine. as far as i could figure out up to now everything works perfectly. for instance: i can create databases and tables in phpmyadmin; i can enter data into them in phpmyadmin and i can search the database in the same surface.
the readme-file of xampp says that
With the preset values, you'll have to use the following syntax: mysql_connect("localhost","root","");

but when i use this action in php my page can't connect to the database. it doesn't return an error neither.
in my php-file i programmed the following to get at least any result:
function printError($errorMesg)
{
printf("<br> %s <br>\n", $errorMesg);
}
if (!($link = mysql_connect("localhost","root","")));
{
printError(sprintf("error connecting to host %s, by user %s", $host, $user)); exit();
}

when running the script, it answers;
error connecting to host localhost, by user root


i didn't change anything in the configuration of any of the programs in xampp.

the truth is out there, they say, thus i hope it will find its way here :wink:
covenant
 
Posts: 1
Joined: 11. June 2004 10:31

Postby Wiedmann » 11. June 2004 11:30

Code: Select all
function printError($errorMesg)
{
printf("<br> %s <br>\n", $errorMesg);
}
if (!($link = mysql_connect("localhost","root","")));
{
printError(sprintf("error connecting to host %s, by user %s", $host, $user)); exit();
}



Try this code to make connection to the database:
Code: Select all
$link = mysql_connect('localhost', 'root', '')
   or die ('error connecting to host: '.mysql_error());

What happens?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby free69 » 13. June 2004 23:35

Code: Select all
function printError($errorMesg)
{
printf("<br> %s <br>\n", $errorMesg);
}
if (!($link = mysql_connect("localhost","root","")));
{
printError(sprintf("error connecting to host %s, by user %s", $host, $user)); exit();
}


I think you can connect if you put password like this

if (!($link = mysql_connect("localhost","root","password")));
free69
 
Posts: 35
Joined: 02. June 2004 05:52

Postby micha78347 » 14. June 2004 20:51

if your user (eg root) haves no password set then you may use:

if(!$link=mysql_connect('localhost','root')) print "err connecting";
micha78347
 
Posts: 57
Joined: 07. June 2004 20:56

I have the same problem

Postby dekatvandeburen » 23. June 2004 11:08

I have the same problem on my winXP Pro box. PhpMyAdmin works fine, but when i try to connect in my own php scripts, i get nothing. I tried the various codes posted in this topic, but MySql does not return an error, it just doesn't return anything :(

Anyone got an idea how we can fix this? Maybe something in the MySql config or something?
dekatvandeburen
 
Posts: 1
Joined: 23. June 2004 11:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 48 guests