txt3rob — 2013-12-04T13:54:48-05:00 — #1
any one able to help me to correct this at all please
$importduetimes = $dbh->prepare("LOAD DATA LOCAL INFILE '/tmp/trains.csv' INTO TABLE Trains FIELDS TERMINATED BY ',' IGNORE 1 LINES (Due,Destination,Status,Platform,Details)");
Fatal error: Call to a member function prepare() on a non-object in /var/www/trains/functions.php on line 64
oddz — 2013-12-04T14:13:55-05:00 — #2
$dbh is not in the scope of importdue. You need to either pass it as a argument or make it a global. The former of course is preferred.
txt3rob — 2013-12-04T14:54:17-05:00 — #3
just been reading this should be a global as i've done an include before the function to set it as a global
txt3rob — 2013-12-04T14:57:49-05:00 — #4
just done GLOBAL $dbh now getting closer!
thank you very much!
$sql = "LOAD DATA LOCAL INFILE '/tmp/trains.csv' INSERT INTO TABLE Trains FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\r\
' IGNORE 1 LINES (Due, Destination, Status, Platform, Details)";
$importduetimes = $dbh->query($sql);
still errors out and shows
Fatal error: Call to a member function execute() on a non-object in /var/www/trains/functions.php on line 67
kylewolfe — 2013-12-04T15:35:14-05:00 — #5
run var_dump($dbh);exit; right after global and paste the result
txt3rob — 2013-12-04T15:47:42-05:00 — #6
oddz — 2013-12-04T16:23:15-05:00 — #7
The query method returns false on failure. The reason for this is that the query is malformed/incorrect.
Use errorCode and errorInfo methods to debug query failure.
You can also take the query out of the application and run it directly from the command line to see why it might be failing.
txt3rob — 2013-12-05T04:18:35-05:00 — #8
$importduetimes = $dbh->prepare("LOAD DATA INFILE '/tmp/trains.csv' INTO TABLE `Trains` FIELDS TERMINATED BY ',' IGNORE 1 LINES;");
kylewolfe — 2013-12-05T09:08:09-05:00 — #9
That's concerning that I and everyone else here didn't see that the first time around, lol. Good job
system — 2014-10-08T01:16:08-04:00 — #10
This topic is now closed. New replies are no longer allowed.