I prepare a script which update the field "stock" in the database of my online shop. When I run it ther's no No errors who appears ! However no change occurs at the database So what can be the problem ! It can't access to the database because of it's name ?
Any idea? Here is the code below :
<?php
/*---------------------CONNEXION MYSQL----------------------*/
$servername='';
$database_username='';
$database_password='';
$database_name='';
set_time_limit(1600);
$link = mysql_connect($servername, $database_username, $database_password);
//$link = mysql_connect('mysql5-6.240', 'vintagemvm75', 'pu1df4mu');
if (!$link) {
die('Connexion impossible : ' . mysql_error());
}
echo 'Connecté correctement';
//$link = mysql_connect($servername,$database_username,$database_password) or die("Erreur de connexion au serveur"); //mysql_connect
//mysql_select_db($link, $database_name) or die("Erreur de connexion à la BDD"); //old: mysql_select_db
/*---------------------FIN CONNEXION MYSQL----------------------*/
/*---------------------RÉCUPÉRATION DU FICHIER STOCK et INITIALISATION----------------------*/
$fichier = file("../batch/export_solsys.csv");
$fp = fopen("../batch/export_solsys.csv","r");
$upc= "";
$stock="";
$ligne = 1;
/*---------------------FIN RÉCUP----------------------*/
echo("Parcours du fichier...")."<br/>";
/*---------------------MISE A JOUR DU STOCK----------------------*/
while($tab=fgetcsv($fp,1000,';'))
{
$champs = count($tab);//nombre de champs dans la ligne en question
$ligne++;
$upc = $tab[0];
$stock = $tab[7];
echo("upc: ").$upc."<br/>";
echo("stock: ").$stock."<br/>";
$batch = "SELECT stock FROM declinaison_stock_produit where upc = '56939'";
$requete = mysql_query($batch, $link);
$batch1 ="UPDATE declinaison_stock_produit SET stock = '4' where upc = '56939'";
$requete1 = mysql_query($batch1, $link);
echo("Stock mis à jour ");
echo("Fin de l'éxécution du batch");
}
?>