"Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\Continental\rutas\upload_routes_file.php on line 23"
This is the code:
<?php
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();
//this should the the absolute path to the config.php file
//(ie /home/website/yourdomain/login/config.php or
//the location in relationship to the page being protected - ie ../login/config.php )
require('../config.php');
//this should the the absolute path to the functions.php file - see the instrcutions for config.php above
require('../functions.php');
$link = Conectarse($db_server, $db_name, $db_username, $db_password);
$data = array();
function add_person( $first, $middle, $last, $email )
{
global $data, $dbh;
$sth = $dbh->prepare("INSERT INTO rutas_programadas (fecha, zona, ruta, area) VALUES(?, ?, ?, ?)");
//$dbh->bindParam(1, $first);
//$dbh->bindParam(2, $middle);
//$dbh->bindParam(3, $last);
//$dbh->bindParam(4, $email);
$dbh->execute($sth,array($first,$middle,$last,$email));
//$dbh->execute( $sth, array( $first, $middle, $last, $email ) );
$data []= array(
'first' => $first,
'middle' => $middle,
'last' => $last,
'email' => $email
);
}
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
echo $dom->saveXML();
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
foreach ($rows as $row)
{
if ( !$first_row )
{
$first = "";
$middle = "";
$last = "";
$email = "";
$index = 1;
$cells = $row->getElementsByTagName( 'Cell' );
foreach( $cells as $cell )
{
$ind = $cell->getAttribute( 'Data' );
if ( $ind != null ) $index = $ind;
if ( $index == 1 ) $first = $cell->nodeValue;
if ( $index == 2 ) $middle = $cell->nodeValue;
if ( $index == 3 ) $last = $cell->nodeValue;
if ( $index == 4 ) $email = $cell->nodeValue;
$index += 1;
}
add_person( $first, $middle, $last, $email );
}
$first_row = false;
}
}
?>
<html>
<body>
These records have been added to the database:
<table>
<tr>
<th>First</th>
<th>Middle</th>
<th>Last</th>
<th>Email</th>
</tr>
<?php foreach( $data as $row ) { ?>
<tr>
<td><?php echo( $row['first'] ); ?></td><
<td><?php echo( $row['middle'] ); ?></td><
<td><?php echo( $row['last'] ); ?></td><
<td><?php echo( $row['email'] ); ?></td><
</tr>
<?php } ?>
</table>
Click <a href="list.php">here</a> for the entire table.
</body>
</html>
Can someone help me where the error is??

New Topic/Question
Reply




MultiQuote





|