...

View Full Version : query doesn't run?



maroccano1
02-26-2009, 05:25 PM
I am very new to mysql, i have created the following code to run a query and obtain the results but keep getting this message
"mysqli_fetch_object() expects parameter 1 to be mysqli_result, boolean given in C:\inetpub\wwwroot\create_auction.inc.php on line 26"
i don't understand why??



<?php
include('header.html');
$user = $_SESSION['username'];
$userid = $_SESSION['userid'];

if(!session_is_registered('username')) {
echo "you must be logged in";

}else{

include('connect.php');

$track = $_POST['track'];
$month = $_POST['months'];
$week = $_POST['weeks'];
$rprice = $_POST['rprice'];

$q = "SELECT track_id FROM tracks WHERE username='$user' AND title = '$track'";
//$r = @mysqli_query ($dbc, $q);

$result = @mysqli_query($dbc, $q);
$row=mysqli_fetch_object($result);


}

abduraooft
02-26-2009, 05:36 PM
Try
$result = mysqli_query($dbc, $q) or die(mysql_error()); instead of

$result = @mysqli_query($dbc, $q);

oracleguy
02-26-2009, 05:49 PM
Please wrap your code using the code tags in the future. (Or the php tag if the code is php) I fixed up your post for you.

maroccano1
02-26-2009, 06:13 PM
i added the following, it stops giving an error but does not echo?




$row = mysqli_fetch_object($result);
$trackid = $row->track_id;
echo "$trackid";

Fumigator
02-26-2009, 11:54 PM
Do you know if you even fetched a row? Use mysqli_num_rows() to find out if you did.

http://us2.php.net/manual/en/mysqli-result.num-rows.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum