Jump to content

query doesn't work

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
I have simple code which should edit list of records
    if($_GET['submit'] == 'list')
    {
        $lid = $_GET['lid'];
        $group = $_GET['group'];
        //print_r($_POST);
        foreach($_POST as $vname => $value)
        {
          //$value = $db->escapeString($value);
          $db->readQuery("UPDATE `langvars` SET `langText` = '$value' WHERE `langVar` ='$vname' AND `langID` ='$lid' AND `langGroup` = '$group';");
        }
        Func::showMsg($Lang->getVar('lang.varsedited'),'./lang.php',4);
    }
$db->readQuery("UPDATE `langvars` SET `langText` = '$value' WHERE `langVar` ='$vname' AND `langID` ='$lid' AND `langGroup` = '$group';");
doesn't work for me and I don''t know why!!

#2
DEViANT

DEViANT

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 358 posts
Theres a semicolon in your SQL query... This might cause problems?

Quote

$db->readQuery("AND `langGroup` = '$group';");

:D You should rep+ me so that I can win :D

My Blog | Ask me!
Error : Satan did it

#3
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
No, query is correct. Check the spelling of table names.

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
php's built in functions for MySQL doesn't allow ending semicolon on sql queries, so I agree with DEViANT, remove it and it should work.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#5
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
This query generated by phpMyAdmin
With ; or without ; doesn't work for me.

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
"doesn't work" doesn't help. Try to provide us an error (check your documentation on how to retrieve it), it could be an error at any number of steps. As said before most DB engines cannot cache multiple results, strip the semicolon (PHPMyAdmin does not know what you are using, it only provides a query)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
I user or die(mysql_error());
But I don't get any error!

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts

Hamed said:

I user or die(mysql_error());
But I don't get any error!
You should always check if mysql_affected_rows() will return anything greater than zero, to see if the query actually did anything. You should know what debugging steps can be taken for each action in PHP, this is great knowledge when writing an application.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.