MySQLi prepared statements in PHP
Sorry if I'm not familiar with 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 member function bind_param () for non-object in / home / fallouta / public_html / ocbus / google_transit / stop_times.php on line 67
If anyone can let me know what I am doing wrong? Please let me know.
Note. I need the trip_id value as a non integer string.
Thanks Cyrus
+3
Cyrus kafai wu
source
to share
2 answers
I realized my mistake. The following statement should be included:
$ stmt-> store_result ();
Because you cannot have two requests at the same time. Feel free to add additional information.
+3
Cyrus kafai wu
source
to share
set the parameters first, 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 this is what php.net recommends
+1
maxpovver
source
to share