php & mysql.

Join Discord

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
ok jus started out with this... i been followin a video tut all day, now im @ the point of connecting to the mysql DB

wen i run the .php script, it says this:

Fatal error. Call to undefined function mysql_connect() in C:\Website\rar2.php on line 3

i am following everythin the tut shows, so the code is as follows...

<?
require($_SERVER["DOCUMENT_ROOT@] . "config/db_config.php");
$connection = mysql_connect($db_host, $db_user, $db_password) or die("connection error");
echo "connection made";
?>

i have looked on the php site, and it shows the same function as above to be the one to use.

i got apache, php5 and mysql all running fine. I know its not apache otherwise i wouldnt be able to show the site, i know its not php because i have got a different script which works fine. i know mysql is runnin fine because i have been playing in there.

im using an old archive version of mysql because its the one thats being shown on the tutorial (which was made back in 2002 i think lol and mysql confuses me @ the best of times lol) so i dont know if it could be that :s.

any1 sorta see if they can spot where i might be going wrong 0.o

thnx
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
try this
PHP:
<?php
	include "config/db_config.php";
?>
and in your db_config.php you should have
PHP:
<?php
$connection = mysql_connect("127.0.0.1", "root", "rootpass") or die("Could not connect.");

if(!$connection) 

	die("no connection");

if(!mysql_select_db("databasename",$connection))
 	die("No database selected.");
?>
 

Kaori

LOMCN MiR3 Queen!
VIP
Jun 3, 2004
3,584
38
285
Canada
you may need to enable it here by removing the semicolon in the php.ini

;extension=php_mysql.dll
 

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
nope still no luck ¬¬

i searched the net for solutions and found 5 .dll files to put in system32 folder.. .put them in and still no luck -.-
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
if you havnt got any previously saved databases in sql. try uninstalling apache,mysql, and php.

then install the lastest WAMP. not sure if it will solve ur problem, but got it working for me straight away.
 
Last edited:

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
if you havnt got any previously saved databases in sql. try uninstalling apache,mysql, and php.

then install the lastest WAMP. not sure if it will solve ur problem, but got it working for me straight away.

well i think its working now XD

im jus getin aload of other crap come up now ¬¬ about undefined variables and a warning.

but ty farpfit :D
 

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
ok now all i am getting is this:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'php'@'localhost' (using password: YES) in C:\wamp\www\rar2.php on line 3

kinda starting to suck ass now lol. is there something i have to change to allow password use or summit??

oh and i have set the user up in mysql fine :s
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
thats for mysql, when u installed wamp or whatever your using u must have set a password.

it not goto http://127.0.0.1 to locate phpmyadmin

details should be in there.

edit:

also what have you set in your config file? have u actually put your ip,dbname and dbpass?
 
Last edited:

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
yeah, i set up a new user, set the password the user name permissions etc.

and yes the config file holds the user name local ip (127.0.0.1) password and database info. yet it still dont wanna know :(

really gettin on my nurves lol, tis the only thing stoppin me from continuin with my tutorials ¬¬
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
try removing the password from mysql altogether
 

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
nope just says (using password: NO) now ¬¬

really startin to bug me now lol
 

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
could this have anything to do with it:

your PHP MySQL library version 5.0.51a differs from your MySQL server version 5.1.32. This may cause unpredictable behavior.
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
no idea sorry, im not really that clued up on php and mysql, im just letting u know the stuff iv learnt over the last few months.

i tried just using the latest wamp instead?
 

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
yeah i got the latest wamp.

nps im sure some1 will come up with summit or ill find a solution somewhere lol.

it connects fine with root user tho ¬¬ jus not with my made one -.-
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,184
30
2,788
540
ah right. yeah i always use root.

have you set all the permissions correctly?
 

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
well on the tutorial it told me to only set the 1st 4 permissions. altho wen i created it i forgot to set a number for a couple of parts so it bought up kinda like an error when the user is created :s lol. ill try making another and settin summit in there lol >.<
 

Kaori

LOMCN MiR3 Queen!
VIP
Jun 3, 2004
3,584
38
285
Canada
how did you create your db and user? the following will create a database called php, user php with password php

login as root

mysql -u root -p

create database php default character set utf8;
grant all on php.* to 'php'@'localhost' identified by 'php' with grant option;
grant all on php.* to 'php'@'localhost.localdomain' identified by 'php' with grant option;
 
Last edited:

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
i created them through phpmyadmin.

what you have just done there means fook all to me kaori XD. is that bein done through the cmd window?
 

Kaori

LOMCN MiR3 Queen!
VIP
Jun 3, 2004
3,584
38
285
Canada
yes cmd is much easier for that one...

you can do those in phpmyadmin

login to phpmyadmin as root

and then paste those 3 lines in the sql query window.
 

GOMEEE

LOMCN Veteran
Veteran
Mar 5, 2009
259
0
42
it doesnt ask me to log on with nothing tho :s

i jsut type in localhost into the browser n it opens up the main wamp page then select phpmyadmin. i wil try it through cmd tho :)