[SOLVED] PHP: undefined mysql_connect() call

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
Zephyr
Forum Newbie
Posts: 5
Joined: Wed Sep 01, 2004 4:54 pm

[SOLVED] PHP: undefined mysql_connect() call

Post by Zephyr »

Hi!

I have a problem with setting up the newly downloaded copy of PHP 5.0.1, for windows, for Apache 2.0.50 to work as a module.

When I run this code:

Code: Select all

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body><?php
$link = mysql_connect("localhost", "my_user", "my_password");

/* check connection */ 
if (!$link) {
   printf("Connect failed: %s\n", mysqli_connect_error());
   exit();
}

printf("Host information: %s\n", mysqli_get_host_info($link));

/* close connection */
mysql_close($link);
?>
 </body>
</html>
with php.exe -f above_code.php, it returns this error:

Code: Select all

PHP Fatal error:  Call to undefined function mysql_connect() in above_code.php line 6.
The above code is copied from the php.net documentation.

The same problem occurs for the mysqli object... I assume I did not setup the php interpreter correctly. I need help in correcting this so that I can connect to my database (which is however setup and works).

Thank you in advance for your assistance.

Bye
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

lilPunkSkater's install guide.. ::
http://lps.no-ip.org/install.php
Zephyr
Forum Newbie
Posts: 5
Joined: Wed Sep 01, 2004 4:54 pm

Post by Zephyr »

Thank you feyd for such quick reply, but the link does not work - the page cannot be displayed.

Could you please give me another link for that?

Thank you very much

EDITED: Sure I will wait. Thank you, I didn't know :o
Last edited by Zephyr on Wed Sep 01, 2004 5:17 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll have to wait until he comes online or starts his computer at least :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Zephyr
Forum Newbie
Posts: 5
Joined: Wed Sep 01, 2004 4:54 pm

Post by Zephyr »

Thank you again for your effort, but I didn't manage to solve the problem.

What I have done:
- Deleted PHP completely (from System etc.) and followed the instructions on that page
- restarted Apache

This didn't work - I still get the same message.

Note: This error only happens when I use the mysql_connect or mysqli_connect methods, otherwise, the code is parsed and interpreted correctly - only if there are no attempts to connect to a database via mysql_connect et simile.

I hope I'm not beginning to annoy you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you have to enable the extension in your php.ini too.
Zephyr
Forum Newbie
Posts: 5
Joined: Wed Sep 01, 2004 4:54 pm

Post by Zephyr »

I'm baffled. It seems that I'm at my wits' end.

I have uncommented this line:

Code: Select all

extension=php_mysql.dll
But when I restart apache, it throws an error that the php_mysql.dll could not be found - hence, it still doesn't work... I have tried and placed php_mysql.dll into many different locations: windoze/system32, php/, apache/bin, apache/ etc. etc.

Man, I'm hopeless. I'm really sorry I can't get it right, but I need your help.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Zephyr
Forum Newbie
Posts: 5
Joined: Wed Sep 01, 2004 4:54 pm

Post by Zephyr »

Thanks to you, feyd, everything is working now - thanks to your found threads - especially the very last one!

This is what I had to do:
1. put the php.ini into the C:\PHP directory (with the extensions uncommented)
2. put the libmysql.dll and libmysqli.dll into the %SYSTEMROOT% directory.
3. restart my Vinetou (read Apache)

Note: I have thought that php.ini should be in the %systemroot% directory...

Thank you very much, feyd! You helped me to solve the problem.
Post Reply