Page 1 of 1
undefined function...pls help
Posted: Thu Dec 01, 2005 4:05 am
by pleigh
hello, im using xampp now to make my life easier

...but i think it doesn't change what my problem when i installed apache, php5, mysql separately...you see, this code will successfully connect to the database
Code: Select all
$host = 'localhost';
$user = 'root';
$pass = 'anypassword';
$connect = mysql_connect($host, $user, $pass) or die("Check your server connection.");
but when it reaches this function
Code: Select all
mysql_create_db("wiley") or die(mysql_error());
the browser returns a fatal error
Call to undefined function: mysql_create_db() in C:\XAMPP\xampp\htdocs\sample\_debug_tmp.php on line 13
by default, these extensions are uncommented in the php.ini of xampp
Code: Select all
extension=php_mysql.dll
extension=php_mysqli.dll
i tried to do mysqli_create_db() but still, fatal error...i really need your help on this..thanks in advance..

Posted: Thu Dec 01, 2005 4:18 am
by phpdevuk
php.net recommends the following instead of mysql_create_db as it is depreciated, try this
Code: Select all
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sql = 'CREATE DATABASE my_db';
if (mysql_query($sql, $link)) {
echo "Database my_db created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>
Posted: Thu Dec 01, 2005 4:22 am
by n00b Saibot
As far as I remember reading, both dlls should not be uncommented

Posted: Thu Dec 01, 2005 4:27 am
by pleigh
n00b Saibot wrote:As far as I remember reading, both dlls should not be uncommented

thanks...refering to the other post/topic, i thought you said
n00b Saibot wrote:as far as I can remember you have to uncomment php_mysql/mysqli.dll whichever you prefer in php.ini...
Posted: Thu Dec 01, 2005 4:30 am
by Jenk
php_mysqli.dll if you want to use mysqli_* functions and functionality
php_mysql.dll if you want to use mysql_* functions and functionality.
Have read on php.net to discover the difference(s) between the two.
Posted: Thu Dec 01, 2005 4:35 am
by pleigh
phpdevuk wrote:php.net recommends the following instead of mysql_create_db as it is depreciated, try this
Code: Select all
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sql = 'CREATE DATABASE my_db';
if (mysql_query($sql, $link)) {
echo "Database my_db created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>
hi, thanks...i tried the above code and it generates an warning...
Code: Select all
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\XAMPP\xampp\htdocs\sample\_debug_tmp.php on line 14
Error creating database: No database selected
Posted: Thu Dec 01, 2005 6:05 am
by phpdevuk
you did replace the username and password and database name in that example with your details?
Posted: Thu Dec 01, 2005 6:09 am
by Jenk
'or die' would have been triggered if they were wrong details.
Posted: Thu Dec 01, 2005 6:26 am
by phpdevuk
true, hehe didn't think
