Reputation: 149
Sorry if I seem new to this.
if(!isset($stmt_counttime)) { $stmt_counttime = $mysqli->prepare("SELECT count(1) as count FROM `stop_times` where `stop_id` = ? and `trip_id` = ? LIMIT 1");
$stmt_counttime->bind_param('ss',$stop_id,$trip_id); }
$stop_id = $data[3];
$trip_id = $data[0];
$stmt_counttime->execute();
$stmt_counttime->bind_result($count_time_result);
$stmt_counttime->fetch();
if(!isset($stmt_counttrip)) { $stmt_counttrip = $mysqli->prepare("SELECT count(1) as count FROM `trips` where `trip_id` = ?");
$stmt_counttrip->bind_param('s',$tripid);
}
$tripid = $data[0];
$stmt_counttrip->execute();
$stmt_counttrip->bind_result($count_trip_result);
$stmt_counttrip->fetch();
Line 67: $stmt_counttrip->bind_param('s',$tripid);
Error: Fatal error: Call to a member function bind_param() on a non-object in /home/fallouta/public_html/ocbus/google_transit/stop_times.php on line 67
If anyone could let me know, what I am doing wrong? Please let me know.
Note: I need trip_id's value as string not integer.
Thanks, Cyrus
Upvotes: 3
Views: 50
Reputation: 1600
first set params, then bind them:
$stop_id = $data[3];
$trip_id = $data[0];
$stmt_counttime->bind_param('ss',$stop_id,$trip_id);
and
$tripid = $data[0];
$stmt_counttrip->bind_param('s',$tripid);
at least that is what php.net recommends
Upvotes: 1
Reputation: 149
I realized my mistake. One should include the following statement:
$stmt->store_result();
Because you can't have two queries simultaneously. Feel free to add more information.
Upvotes: 3