I'm trying to be able to paste a proxy list into a Text file and be able to update the rows status to 1 if the pasted proxy is in the Database. I got it kind of working im using explode to seperate the list and from there foreach it using a query function. The issue is it doesnt update. It works on the very last proxy only.
Query Function:
function Connect($host = false,$username = false,$password = false,$dbname = false) {
//Try execute the PHP with no errors;
try {
//Create a PDO Session;
$con = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
//Session Attributes;
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$con->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
//Catch all PDOException errors;
catch (PDOException $e) {
//Make the PDO session false;
$con = false;
}
//If no errors happened Make the PDO session true;
return $con;
}
//Create a new function named query;
function query($sql = false,$dbname = false,$bind = false,$obj = false) {
//Prepare The SQL Query;
$query = Connect('localhost','xx','xx',$dbname)->prepare($sql);
$res = true;
//Execute Binded Query;
try { $query->execute($bind); $res = true; }
catch (PDOException $e) {
$res = false;
}
//If no errors happened Make $row true;
return $res;
}
And PHP:
<?php
//Define if Error Logging will be turned on (true) or off (false);
$errorlogging = true;
$obstart = false;
$adminonly = false;
//Set the default Timezone to UK/Ireland;
date_default_timezone_set('Europe/London');
//Globalized functionality needed on all pages;
require('common/requisites.php');
//Include The Database Connection;
require('common/db.php');
if(!empty($_POST['proxies'])) {
$proxyinput = $_POST['proxies'];
$proxies = explode("
",$proxyinput);
foreach($proxies as $proxy) {
query('UPDATE proxies SET status = 1 WHERE :proxy = proxy','unfed_tools',array(':proxy'=>$proxy));
echo "Updated: ".$proxy."
";
}
}
?>
<form action="" method="post">
<textarea name="proxies" style="height: 300px; width: 300px;"></textarea>
<button type="submit">Click</button>
</form>