Page 1 of 1

db connect

Posted: Sat Jun 09, 2007 12:42 pm
by var_php
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi there 

can anyone see why i keep getting this :Object id #2
as my result for connect to a Mysql db.

Code: Select all

<?php
$user = "mysql";
$host = "localhost";
$password = "mysql";
$database = "db";
$connection = mysqli_connect($host,$user,$password);
if (!$connection){
echo ("<b>unable to connect to the mysql server at this time</b>");
exit();
}

mysqli_select_db($connection,$database);
if(!mysqli_select_db){
exit("<b>unable to connect to signaturedb</b>");
}

$query = "SELECT user_id FROM user LIMIT 10";
$result = mysqli_query($connection,$query);
print $result;
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Jun 09, 2007 12:48 pm
by volka

Posted: Sat Jun 09, 2007 1:00 pm
by var_php
thanks Volka will have a look so if i understand it correctly i should be using "mysqli_fetch_array," instead of "mysqli_query" ?

Posted: Sat Jun 09, 2007 1:14 pm
by John Cartwright
you need to use them both