Ok, i try to make an update query with PDO MYSQL so to learn how make it work and then make a function to make it more efficiently
The problem is doesn't work, i do all the debugg the Log files allow me, and the personal returns too, i alsy fix wherever the navigator tell & even with Firebug
Any ideas what can be?
Any suggestion, question, comment or any kind of answer than help to improve, clarify or answer the question would be much aprreciated
Thanks in advance
<?php
include('conexion.php');
session_start();
$idf = $_POST['Id_Msg'];
$ids = (int) $idf;
var_dump($ids);
echo '<br /><br />';
var_dump($_FILES);
echo '<br /><br />';
var_dump($_POST);
echo '<br /><br />';
$wlq = -1;
if($_POST['Title']) {
$wlq++;
}
if($_POST['Prelude']) {
$wlq++;
}
if($_POST['Text']) {
$wlq++;
}
if($_POST['NOMBR1']) {
$wlq++;
}
if($_POST['NOMBR2']) {
$wlq++;
}
if($_POST['NOMBR3']) {
$wlq++;
}
if($_POST['NOMBR4']) {
$wlq++;
}
if($_POST['REGIN']) {
$wlq++;
}
if($_POST['CTGRY']) {
$wlq++;
}
if(!empty($_FILES['RutIm']['name'])) {
$wlq++;
echo 'me esta detectando visteh!';
}
echo "Asignado es: ".$wlq.'<br /><br />';
$qls = "UPDATE `cmtmplo` SET";
if($_POST['Title']) {
if($wlq > 0){
$qls .=" `Title` = :Title , ";
$wlq--;
} else {
$qls .=" `Title` = :Title";
}
}
if($_POST['Prelude']) {
if($wlq > 0){
$qls .=" `Prelude` = :Prelude , ";
$wlq--;
} else {
$qls .=" `Prelude` = :Prelude";
}
}
if($_POST['Text']) {
if($wlq > 0){
$qls .=" `Text` = :Text , ";
$wlq--;
} else {
$qls .=" `Text` = :Text";
}
}
if($_POST['NOMBR1']) {
if($wlq > 0){
$qls .=" `NOMBR1` = :NOMBR1 , ";
$wlq--;
} else {
$qls .=" `NOMBR1` = :NOMBR1";
}
}
if($_POST['NOMBR2']) {
if($wlq > 0){
$qls .=" `NOMBR2` = :NOMBR2 , ";
$wlq--;
} else {
$qls .=" `NOMBR2` = :NOMBR2";
}
}
if($_POST['NOMBR3']) {
if($wlq > 0){
$qls .=" `NOMBR3` = :NOMBR3 , ";
$wlq--;
} else {
$qls .=" `NOMBR3` = :NOMBR3";
}
}
if($_POST['NOMBR4']) {
if($wlq > 0){
$qls .=" `NOMBR4` = :NOMBR4 , ";
$wlq--;
} else {
$qls .=" `NOMBR4` = :NOMBR4";
}
}
if($_POST['REGIN']) {
if($wlq > 0){
$qls .=" `REGIN` = :REGIN , ";
$wlq--;
} else {
$qls .=" `REGIN` = :REGIN";
}
}
if($_POST['CTGRY']) {
if($wlq > 0){
$qls .=" `CTGRY` = :CTGRY , ";
$wlq--;
} else {
$qls .=" `CTGRY` = :CTGRY";
}
}
if(!empty($_FILES['RutIm']['name'])) {
if($wlq > 0){
$qls .=" `RutIm` = :RutIm , ";
$wlq--;
} else {
}
}
$qls .= " WHERE 'Id_Msg' = :ids";
echo $qls;
$stmt = $con->prepare($qls);
$stmt->bindValue(':ids', $ids);
if(isset($_POST['Title']) && !empty($_POST['Title'])) {
$stmt->bindValue('Title', $_POST['Title']);
}
if(isset($_POST['Prelude']) && !empty($_POST['Prelude'])) {
$stmt->bindValue('Prelude', $_POST['Prelude']);
}
if(isset($_POST['Text']) && !empty($_POST['Text'])) {
$stmt->bindValue('Text', $_POST['Text']);
}
if(isset($_POST['NOMBR1']) && !empty($_POST['NOMBR1'])) {
$stmt->bindValue('NOMBR1', $_POST['NOMBR1']);
}
if(isset($_POST['NOMBR2']) && !empty($_POST['NOMBR2'])) {
$stmt->bindValue('NOMBR2', $_POST['NOMBR2']);
}
if(isset($_POST['NOMBR3']) && !empty($_POST['NOMBR3'])) {
$stmt->bindValue('NOMBR3', $_POST['NOMBR3']);
}
if(isset($_POST['NOMBR4']) && !empty($_POST['NOMBR4'])) {
$stmt->bindValue('NOMBR4', $_POST['NOMBR4']);
}
if(isset($_POST['REGIN']) && !empty($_POST['REGIN'])) {
$stmt->bindValue('REGIN', $_POST['REGIN']);
}
if(isset($_POST['CTGRY']) && !empty($_POST['CTGRY'])) {
$stmt->bindValue('CTGRY', $_POST['CTGRY']);
}
if(!empty($_FILES['RutIm']['name'])) {
$carpeta = "images/";
opendir($carpeta);
$destiny = $carpeta.$_FILES['RutIm']['name'].".jpg";
copy($_FILES['RutIm']['tmp_name'],$destiny);
$skr=$_FILES['RutIm']['name'];
$stmt->bindValue('RutIm', $skr);
}
$stmt->execute();
?>
echo $qls output
UPDATE cmtmplo SET Title = :Title , REGIN = :REGIN , CTGRY = :CTGRY WHERE 'Id_Msg' = :ids
echo $qls;outputs?cmtmploSETTitle= :Title ,REGIN= :REGIN ,CTGRY= :CTGRY WHERE 'Id_Msg' = :ids$qlsplease?echo $qls;before your$con->prepare!