[SOLVED] no result connecting to mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
FREESTYLER
Forum Newbie
Posts: 17
Joined: Tue Oct 18, 2005 10:33 am

[SOLVED] no result connecting to mysql

Post 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
Last edited by FREESTYLER on Tue Oct 18, 2005 11:51 pm, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
FREESTYLER
Forum Newbie
Posts: 17
Joined: Tue Oct 18, 2005 10:33 am

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
FREESTYLER
Forum Newbie
Posts: 17
Joined: Tue Oct 18, 2005 10:33 am

Post 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
FREESTYLER
Forum Newbie
Posts: 17
Joined: Tue Oct 18, 2005 10:33 am

Post 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
FREESTYLER
Forum Newbie
Posts: 17
Joined: Tue Oct 18, 2005 10:33 am

Post 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)
Post Reply