Page 1 of 1

[SOLVED] no result connecting to mysql

Posted: Tue Oct 18, 2005 10:45 am
by FREESTYLER
hey guys
im new to php, been using java (jsp's) and mysql for awhile
im running windows 2000
set up php5, mysql4.1, apache2
all set up and working together so it seems

trying to connect to mysql with php but i get no results or anything after my first line of code (the connect statement)
i done a quick search and didnt find to much on this topic,
heres my code

Code: Select all

$connect = mysql_connect("localhost", "*****", "******")
        or die('could not connect to database; ' . mysql_error());

    mysql_select_db("channel7", $connect);

    $query = "Select name, position from satellites";

    $results = mysql_query($query)
        or die('could not connect to database; ' . mysql_error());

    while ($row = mysql_fetch_array($results)) {
        extract($row);
        echo $name;
        echo "<br>1";
        echo $position;
    }
ive put some echo "test"; in to see if its getting past certain blocks of code and i get no return after the $connect = mysql_connect statment
any help
cheers
Neill

Posted: Tue Oct 18, 2005 11:03 am
by Chris Corbyn
Can you connect to mysql from the command line? (i.e. Is it running OK?)

The code looks fine.

Note: I've removed your database credentials... remember not to post them in public ;)

Posted: Tue Oct 18, 2005 11:07 am
by FREESTYLER
yeah mysql works fine
ive been using it via java

oops on the database details :oops: didnt think..

no idea why its not working ive been reading for hours on it now

thanks for your help

Posted: Tue Oct 18, 2005 11:13 am
by Chris Corbyn
Put

Code: Select all

error_reporting(E_ALL);
on the top of your PHP code please and then post any errors you get :)

Posted: Tue Oct 18, 2005 9:33 pm
by FREESTYLER
yeah i tried that just after i posted this topic
it came back with no errors anywhere
where would it print out the error's, in the browser?
or in the tomcat apache log
ive looked everywhere and it dosnt show any

Posted: Tue Oct 18, 2005 10:23 pm
by FREESTYLER
ok, i downloaded phpED editor and run my file in there and got this error output

Fatal error: Call to undefined function mysql_connect() in C:\Documents and Settings\Neill Horsman\WebApplication1\web\index.php on line 12

im asumming i dont have the mysql php package installed
where do i get this?
thanks
Neill

Posted: Tue Oct 18, 2005 11:52 pm
by FREESTYLER
managed to fix this myself, done some reading and found i hadnt copied libmysql.dll to the sys32 dir of windows.
and changed a path name in a php.ini, that i thought i had changed already.
thanks for your help guys 8)