Hi,
i am french and it is difficult to explain my problem.
i make an form with chronoform v5, i want to delete a row of my base and i don't do it yet !
i made a program in php that works perfectly out of chronoform but when I include it in custom code the line is not deleted. I have been searching for a few days and I despair of finding a solution.
I am adding the code I put in the custom code;
Thank you in advance for you answer
i am french and it is difficult to explain my problem.
i make an form with chronoform v5, i want to delete a row of my base and i don't do it yet !
i made a program in php that works perfectly out of chronoform but when I include it in custom code the line is not deleted. I have been searching for a few days and I despair of finding a solution.
I am adding the code I put in the custom code;
Thank you in advance for you answer
<?php
try
{
// On se connecte à MySQL
$bdd = new PDO('mysql:host=localhost;dbname=essai_cf', 'root', '');
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
echo 'base ouverte';
$num =$form -> data['id'];
$bdd->exec("DELETE from numéro WHERE id ='$num' ");//
echo 'La fiche '.$num.' a été supprimée';
?>
Hi marmouz,
The code looks ok, do you get any errors ?
if you use Chronoforms version 6 then there is a delete data action which you can use to delete any rows from any database table, and its better to do it that way.
Best regards,
Max
The code looks ok, do you get any errors ?
if you use Chronoforms version 6 then there is a delete data action which you can use to delete any rows from any database table, and its better to do it that way.
Best regards,
Max
Hi Marmouz,
In CFv5 I suggest that you add another debug line like this
Bob
In CFv5 I suggest that you add another debug line like this
. . .
echo 'base ouverte';
$num =$form -> data['id'];
$query = "DELETE from numéro WHERE id ='$num' ";
echo'<div>$query: '.print_r($query, true).'</div>';
$bdd->exec($query);
echo 'La fiche '.$num.' a été supprimée';
?>
That should show you the query being created and you can test that in PHPMyAdmin to see if it works there.
Bob
Thanks for your quick answers.
I tried the suggestion of Greyhead but as an answer I have the $ query displayed but the line dde the base is not erased.
Where to write these lines of code. For now I wrote them in a custom code it's a mistake ?
Can I use the chronoform v5 or v6 at the same time ?
Is it more interesting to use the v6 with joomla 3.x?
Pierre
I tried the suggestion of Greyhead but as an answer I have the $ query displayed but the line dde the base is not erased.
Where to write these lines of code. For now I wrote them in a custom code it's a mistake ?
Can I use the chronoform v5 or v6 at the same time ?
Is it more interesting to use the v6 with joomla 3.x?
Pierre
Hi Pierre,
If you copy and paste the query into PHPMyAdmin does it delete the row there?
If it does then most likely your connection to the database isn't working.
Bob
If you copy and paste the query into PHPMyAdmin does it delete the row there?
If it does then most likely your connection to the database isn't working.
Bob
Hi Pierre,
Yes, v6 can be used with v5 on the same website.
Best regards,
Max
Yes, v6 can be used with v5 on the same website.
Best regards,
Max
Bob :
"DELETE from numéro WHERE id =$num ";
Yes this code like the one I had used in my first post works and erases the record but is ineffective in chronoform, which is why I am very annoyed.
Max ; Is the V6 better and more stable than the V5 ?
Pierre
"DELETE from numéro WHERE id =$num ";
Yes this code like the one I had used in my first post works and erases the record but is ineffective in chronoform, which is why I am very annoyed.
Max ; Is the V6 better and more stable than the V5 ?
Pierre
Hi Pierre,
v6 is better, the first release was about 1 week ago, some glitches have been found, but none should affect the feature you are going to test here, so if you can get it working then apply the next update all should be good.
Best regards,
Max
v6 is better, the first release was about 1 week ago, some glitches have been found, but none should affect the feature you are going to test here, so if you can get it working then apply the next update all should be good.
Best regards,
Max
Hi Pierre,
But that query will not work unless $num is replaced with a value. It looks as though that is not happening. Please try
Bob
But that query will not work unless $num is replaced with a value. It looks as though that is not happening. Please try
$query = "DELETE FROM `numéro` WHERE `id` = {$num} ";
Bob
Bob : Of course I tried with a value to clear the line in PHPadmin. It is not the variable that is involved, I retrieve it very well in my program in PHP (see my first message).
I try $num and {$num} without success.
Max: Thank you very much I will try.
I try $num and {$num} without success.
Max: Thank you very much I will try.
Hi Pierre,
It is not possible to tell from the information here exactly what you are doing and where.
What exactly is output as the value of $query?
Does that work in PHPMyAdmin?
Please drag a Debugger action into the On Submit event, then submit the form and copy and paste the debug results here.
Bob
It is not possible to tell from the information here exactly what you are doing and where.
What exactly is output as the value of $query?
Does that work in PHPMyAdmin?
Please drag a Debugger action into the On Submit event, then submit the form and copy and paste the debug results here.
Bob
Hi Bob,
I have in my first message indicated the program I had written in PHP in FC and used by a redirect.
When I use redirection the line is eliminated and when I place the program in FC by a custom code the Degugger does not bring me any error message.
I join the program placed in custom code and the image of the debugger.
Thank for your kindness
Pïerre
I have in my first message indicated the program I had written in PHP in FC and used by a redirect.
When I use redirection the line is eliminated and when I place the program in FC by a custom code the Degugger does not bring me any error message.
I join the program placed in custom code and the image of the debugger.
<?php
try
{
// On se connecte à MySQL
$bdd = new PDO('mysql:host=localhost;dbname=essai_cf', 'root', '');
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
echo 'base ouverte';
$num =$form -> data['id'];
//$bdd->exec("DELETE from numéro WHERE id ='$num' ");//
$query = "DELETE from numéro WHERE id ={$num} ";
echo'<div>$query: '.print_r($query, true).'</div>';
$bdd->exec($query);
echo 'La fiche '.$num.' a été supprimée';
?>
Thank for your kindness
Pïerre
Salut Pierre,
You can see from your image that the query created is "DELETE from numéro WHERE id =9"
This looks correct to me except that I think a column name including é has to be quoted i.e. `numéro` as it is in my example.
Bob
You can see from your image that the query created is "DELETE from numéro WHERE id =9"
This looks correct to me except that I think a column name including é has to be quoted i.e. `numéro` as it is in my example.
Bob
Hi Bob,
thanks to you.
I finally found. The error is quite specific to the use of french language. Ah our famous accents! I had named my table 'numéro' and if PHPmyadmind allows for accents CF not.
It was with your last post that I had the idea to rename my table in 'numero' without accent and to copy the syntax of the deletion of a line in PHPmyAdmin. This operation works.
I join after the finally lines of code
$num =$form -> data['id'];
$bdd->exec("DELETE from `essai_cf`.`numero` WHERE `numero`.`id` ={$num} ");
Morality: Never use accents in name of DB elements and give the full names for the table and the fields quoted i.e : 'base'. 'table' and 'table'.'field'
You may closed the post.
Thanks again for your help, your french friend,
Pierre
thanks to you.
I finally found. The error is quite specific to the use of french language. Ah our famous accents! I had named my table 'numéro' and if PHPmyadmind allows for accents CF not.
It was with your last post that I had the idea to rename my table in 'numero' without accent and to copy the syntax of the deletion of a line in PHPmyAdmin. This operation works.
I join after the finally lines of code
$num =$form -> data['id'];
$bdd->exec("DELETE from `essai_cf`.`numero` WHERE `numero`.`id` ={$num} ");
Morality: Never use accents in name of DB elements and give the full names for the table and the fields quoted i.e : 'base'. 'table' and 'table'.'field'
You may closed the post.
Thanks again for your help, your french friend,
Pierre
This topic is locked and no more replies can be posted.