Re: Probleme with MySQL queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Did you change $var=108; into$var=mysql_real_escape_string($_GET['deleteid'])? :
if (isset($_GET['deleteid'])){        $var=mysql_real_escape_string($_GET['deleteid']);        $query = mysql_query("SELECT * FROM table WHERE id={$var};") or        die("select error: " . mysql_error());
        if ($row = mysql_fetch_assoc($query)) {            var_dump ($row);            $query = mysql_query("DELETE FROM table WHERE id={$var}") or            die("delete error: " . mysql_error());        }}
On Wed, Sep 3, 2008 at 12:57 PM, David DURIEUX <d.durieux@xxxxxxxxxxxxx> wrote:> Bonjour,>> array(2) { ["module"]=>  string(12) "sousdomaines" ["deleteid"]=>> string(3) "133" }>>> Note : The ID is good deleted but no select return>> Cordialement,>> David DURIEUX> Tel : 04.74.04.81.34> Port : 06.34.99.45.18> Mail : d.durieux@xxxxxxxxxxxxx> Site Web : http://www.siprossii.com/>> SIPROSSII> 847 route de Frans (Créacité)> 69400 Villefranche sur Saône>>>> Le Wed, 3 Sep 2008 12:54:19 +0200> "Evert Lammerts" <evert.lammerts@xxxxxxxxx> a écrit:>>>What does var_dump($_GET) say?>>>>On Wed, Sep 3, 2008 at 12:48 PM, David DURIEUX>><d.durieux@xxxxxxxxxxxxx> wrote:>>> Bonjour,>>>>>> The query works>>>>>> But when I wrote this :>>>>>>>>> if (isset($_GET['deleteid'])){>>>>>>        $var=108;>>>        $query = mysql_query("SELECT * FROM table WHERE id={$var};")>>> or die("select error: " . mysql_error());>>>>>>        if ($row = mysql_fetch_assoc($query))>>>        var_dump ($row);>>>>>>        $query = mysql_query("DELETE FROM table WHERE id={$var}") or>>>        die("delete error: " . mysql_error());>>>>>>>>> }>>>>>>>>> It not works and no return and no error .>>>>>> If I place the query you have sent me without the if it works but I>>> must have a if for delete the ID>>>>>> It is very strange>>>>>> Cordialement,>>>>>> David DURIEUX>>> Tel : 04.74.04.81.34>>> Port : 06.34.99.45.18>>> Mail : d.durieux@xxxxxxxxxxxxx>>> Site Web : http://www.siprossii.com/>>>>>> SIPROSSII>>> 847 route de Frans (Créacité)>>> 69400 Villefranche sur Saône>>>>>>>>>>>> Le Wed, 3 Sep 2008 12:39:45 +0200>>> "Evert Lammerts" <evert.lammerts@xxxxxxxxx> a écrit:>>>>>>>Fixed then?>>>>>>>>On Wed, Sep 3, 2008 at 12:39 PM, David DURIEUX>>>><d.durieux@xxxxxxxxxxxxx> wrote:>>>>> Bonjour,>>>>>>>>>> Yes I have the values>>>>>>>>>> array(5) { ["id"]=>  string(3) "121" ["domaine"]=>  string(1)>>>>> "1" ["sous_domaine"]=>  string(8) "aaaaaaaa" ["repertoire"]=>>>>>> string(0) "" ["redirection"]=>  string(1) "0" }>>>>>>>>>>>>>>> Cordialement,>>>>>>>>>> David DURIEUX>>>>> Tel : 04.74.04.81.34>>>>> Port : 06.34.99.45.18>>>>> Mail : d.durieux@xxxxxxxxxxxxx>>>>> Site Web : http://www.siprossii.com/>>>>>>>>>> SIPROSSII>>>>> 847 route de Frans (Créacité)>>>>> 69400 Villefranche sur Saône>>>>>>>>>>>>>>>>>>>> Le Wed, 3 Sep 2008 12:36:43 +0200>>>>> "Evert Lammerts" <evert.lammerts@xxxxxxxxx> a écrit:>>>>>>>>>>>I keep on making mistakes. $data should be $row in the var_dump ->>>>>>but right now your DELETE has already deleted id 17 (the fact that>>>>>>it prints NULL means the if condition was satisfied). So replace>>>>>>the below code with a different $var value:>>>>>>>>>>>>$var=107;>>>>>>$query = mysql_query("SELECT * FROM table WHERE id={$var};") or>>>>>>die("select error: " . mysql_error());>>>>>>>>>>>>if ($row = mysql_fetch_assoc($query))>>>>>> var_dump ($row);>>>>>>>>>>>>$query = mysql_query("DELETE FROM table WHERE id={$var}") or>>>>>>die("delete error: " . mysql_error());>>>>>>>>>>>>On Wed, Sep 3, 2008 at 12:33 PM, David DURIEUX>>>>>><d.durieux@xxxxxxxxxxxxx> wrote:>>>>>>> Bonjour,>>>>>>>>>>>>>> I have :>>>>>>>>>>>>>> NULL>>>>>>>>>>>>>>>>>>>>>>>>>>>> Cordialement,>>>>>>>>>>>>>> David DURIEUX>>>>>>> Tel : 04.74.04.81.34>>>>>>> Port : 06.34.99.45.18>>>>>>> Mail : d.durieux@xxxxxxxxxxxxx>>>>>>> Site Web : http://www.siprossii.com/>>>>>>>>>>>>>> SIPROSSII>>>>>>> 847 route de Frans (Créacité)>>>>>>> 69400 Villefranche sur Saône>>>>>>>>>>>>>>>>>>>>>>>>>>>> Le Wed, 3 Sep 2008 12:29:44 +0200>>>>>>> "Evert Lammerts" <evert.lammerts@xxxxxxxxx> a écrit:>>>>>>>>>>>>>>>Which means you do get results and your select works.>>>>>>>>>>>>>>>>Now try:>>>>>>>>>>>>>>>>$var=107;>>>>>>>>$query = mysql_query("SELECT * FROM table WHERE id={$var};") or>>>>>>>>die(mysql_error());>>>>>>>>>>>>>>>>if ($row = mysql_fetch_assoc($query))>>>>>>>> var_dump ($data);>>>>>>>>>>>>>>>>$query = mysql_query("DELETE FROM table WHERE id={$var}") or>>>>>>>>die(mysql_error());>>>>>>>>>>>>>>>>On Wed, Sep 3, 2008 at 12:25 PM, David DURIEUX>>>>>>>><d.durieux@xxxxxxxxxxxxx> wrote:>>>>>>>>> Bonjour,>>>>>>>>>>>>>>>>>> string(0) "" int(1)>>>>>>>>> string(0) "" int(1)>>>>>>>>> string(0) "" int(1)>>>>>>>>>>>>>>>>>> Cordialement,>>>>>>>>>>>>>>>>>> David DURIEUX>>>>>>>>> Tel : 04.74.04.81.34>>>>>>>>> Port : 06.34.99.45.18>>>>>>>>> Mail : d.durieux@xxxxxxxxxxxxx>>>>>>>>> Site Web : http://www.siprossii.com/>>>>>>>>>>>>>>>>>> SIPROSSII>>>>>>>>> 847 route de Frans (Créacité)>>>>>>>>> 69400 Villefranche sur Saône>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Le Wed, 03 Sep 2008 05:23:19 -0500>>>>>>>>> Micah Gersten <micah@xxxxxxxxxxx> a écrit:>>>>>>>>>>>>>>>>>>>You have to pass mysql_num_rows a $result variable from your>>>>>>>>>>query.>>>>>>>>>>>>>>>>>>>>Thank you,>>>>>>>>>>Micah Gersten>>>>>>>>>>onShore Networks>>>>>>>>>>Internal Developer>>>>>>>>>>http://www.onshore.com>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>David DURIEUX wrote:>>>>>>>>>>> Bonjour,>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Cordialement,>>>>>>>>>>>>>>>>>>>>>> David DURIEUX>>>>>>>>>>> Tel : 04.74.04.81.34>>>>>>>>>>> Port : 06.34.99.45.18>>>>>>>>>>> Mail : d.durieux@xxxxxxxxxxxxx>>>>>>>>>>> Site Web : http://www.siprossii.com/>>>>>>>>>>>>>>>>>>>>>> SIPROSSII>>>>>>>>>>> 847 route de Frans (Créacité)>>>>>>>>>>> 69400 Villefranche sur Saône>>>>>>>>>>>>>>>>>>>>>> ID is INT. It's ok before.>>>>>>>>>>>>>>>>>>>>>> I have errors :>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Warning: Wrong parameter count for mysql_num_rows()>>>>>>>>>>> in /usr/home/sites/CL000001/Web_data/hebergement/pages/sousdomaines.php>>>>>>>>>>> on line 7 string(0) "" NULL>>>>>>>>>>>>>>>>>>>>>> Warning: Wrong parameter count for mysql_num_rows()>>>>>>>>>>> in /usr/home/sites/CL000001/Web_data/hebergement/pages/sousdomaines.php>>>>>>>>>>> on line 12 string(0) "" NULL>>>>>>>>>>>>>>>>>>>>>> Warning: Wrong parameter count for mysql_num_rows()>>>>>>>>>>> in /usr/home/sites/CL000001/Web_data/hebergement/pages/sousdomaines.php>>>>>>>>>>> on line 16 string(0) "" NULL>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Le Wed, 3 Sep 2008 12:11:00 +0200>>>>>>>>>>> "Evert Lammerts" <evert.lammerts@xxxxxxxxx> a écrit:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> In fact the first return 0 results>>>>>>>>>>>>>>>>>>>>>>>>> So the problem is in your select, and if your select works>>>>>>>>>>>> when you manually insert the value for id (iow, without>>>>>>>>>>>> using $var), the problem has something to do with $var.>>>>>>>>>>>>>>>>>>>>>>>> Is the data type of the ID column INT? Try the following and>>>>>>>>>>>> let us know the output:>>>>>>>>>>>>>>>>>>>>>>>> $var=107;>>>>>>>>>>>> $query = mysql_query("SELECT * FROM table WHERE id={$var};")>>>>>>>>>>>> or die(mysql_error()); // make sure to use double quotes>>>>>>>>>>>> var_dump(mysql_error(), mysql_num_rows());>>>>>>>>>>>>>>>>>>>>>>>> $var=mysql_real_escape_string("107");>>>>>>>>>>>> $query = mysql_query("SELECT * FROM table WHERE id={$var};")>>>>>>>>>>>> or die(mysql_error()); // make sure to use double quotes>>>>>>>>>>>> var_dump(mysql_error(), mysql_num_rows());>>>>>>>>>>>>>>>>>>>>>>>> $query = mysql_query("SELECT * FROM table WHERE id=107;") or>>>>>>>>>>>> die(mysql_error()); // make sure to use double quotes>>>>>>>>>>>> var_dump(mysql_error(), mysql_num_rows());>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->>>>>>>>> PHP Database Mailing List (http://www.php.net/)>>>>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> --> PHP Database Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux