Getting "Parse error: syntax error, unexpected T_ECHO, expecting T_FUNCTION in C:\xampp\htdocs\manipdb2.php on line 34"
Anyone want to take a shot at this one? Practicing manipulating/inserting data into database and trying to learn on my own. No programming background whatsoever, just intrigued by dynamic content and determined to understand it. Thanks in advance!
<?php
$host = 'localhost';
$username = 'root';
$password = '1cdc2slc3';
$db_name = 'my_guitar_shop3';
$db = new mysqli($host, $username, $password, $db_name);
class mysqlii{
public function __construct(&$result_reference,$query,$param=null,&$link=null){
if(!$this->link = $link){
if(!$this->link = &$GLOBALS["db"]){// if no link is passed (default) then use our normal link
$this->throw_execption("no mysqli link present or passed");
}
}
}
function pwrnd($table) {
global $db;
new mysqlii($replace, "select * from `$table`");
foreach($replace as $char){
$newpw = str_shuffle($char['password']);
$q = $db->prepare("update `$table` set `password`=? where `customerID`=?");
$q->bind_param("si", $newpw,$char['customerID']);
$q->execute();
$q->fetch();
$q->close();
}
}
echo " ...creating table\r\n";
$db->query("create temporary table samplecustomers (`customerID` INT(2), `emailAddress` VARCHAR(50),`password` VARCHAR(25),`firstName` VARCHAR(25),`lastName` VARCHAR(25),`shipAddressID` INT(2),`billingAddressID` INT(2), INDEX (`customerID`))";
$db->query("load data local infile 'C:\xampp\htdocs\samplecustomers.csv' into table `samplecustomers` character set utf8 fields terminated by ";" optionally enclosed by '\"' lines terminated by '\r\n' ignore 1 lines (`customerID`,`emailAddress`,`password`,`firstName`, `lastName`, `shipAddressID`, `billingAddressID`)");
echo " ... cleaning customers\r\n";
$clean = pwrnd(samplecustomers);
echo "inserting data ... \r\n";
$db->query("insert into `customers` select `customerID`,`emailAddress`,`password`,`firstName`, `lastName`, `shipAddressID`, `billingAddressID` from samplecustomers");
echo "\r\nDone\r\n";
?>