# You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE rowid = 1' at line 1

**URL:** <https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111>\
**Category:** DoliStore's external modules\
**Created:** [January 18, 2021, 7:37am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111 "2021-01-18T07:37:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![macky](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/m/df788c/32.png) [@macky](https://www.dolibarr.org/forum/u/macky)\
**Post date:** [January 18, 2021, 7:37am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/1 "2021-01-18T07:37:29Z")

</div>

Hi i have this custom module in dolibarr. Im new to it. How can i fix this code that the error says

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE rowid = 1’ at line 1

I think my code is okay

$sql = “UPDATE “.MAIN\_DB\_PREFIX.$this-\>table\_element;  
$sql .= “SET ref = '”.$this-\>db-\>escape($num).”’,”;  
$sql .= “status = “.self::STATUS\_VALIDATED.”,”;  
$sql .= “date\_valid =’”.$this-\>db-\>idate($now)."’,";  
$sql .= "fk\_user\_valid` = ".$user-\>id;  
$sql = "WHERE rowid = ".$this-\>id;

can someone help me figured this thing out?? why the error says in rowid…

Any help is muchly appreciated. TIA

---

<div class="post-metadata">

**Author:** ![ksar](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/ksar/32/514_2.png) [@ksar](https://www.dolibarr.org/forum/u/ksar)\
**Post date:** [January 18, 2021, 9:44am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/2 "2021-01-18T09:44:49Z")

</div>

Hello,

Activate the debug bar and see the complete SQL request syntaxe to understand what is the issue.  
I think a space is missing before WHERE but this need to be investigated.

---

<div class="post-metadata">

**Author:** ![macky](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/m/df788c/32.png) [@macky](https://www.dolibarr.org/forum/u/macky)\
**Post date:** [January 18, 2021, 10:15am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/3 "2021-01-18T10:15:45Z")

</div>

Hi @ksar ,

Yes i already activate the debug bar this is what i see

 ![Screenshot_2021-01-18 PurchaseRequisition(2)](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/4/480780f9e9a455feb824eb01397c549d52ca45ed.png)

It says the line is WHERE

---

<div class="post-metadata">

**Author:** ![ksar](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/ksar/32/514_2.png) [@ksar](https://www.dolibarr.org/forum/u/ksar)\
**Post date:** [January 18, 2021, 10:35am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/4 "2021-01-18T10:35:46Z")

</div>

Debugg bar is a module that you need to activate.  
Then you will have this :

 ![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/3/3de0f02c8e2ebae35dfbad24f7ee8fe98b219bb2.png)

---

<div class="post-metadata">

**Author:** ![macky](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/m/df788c/32.png) [@macky](https://www.dolibarr.org/forum/u/macky)\
**Post date:** [January 18, 2021, 10:38am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/5 "2021-01-18T10:38:05Z")

</div>

Hi @ksar,

Yes i activated that. this is the error

 ![Screenshot_2021-01-18 PurchaseRequisition(3)](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/4/4dacb660bedf20bd0ce1b596d1fd85c49962d281.png)

it clearly says

- ` WHERE rowid = 1` [DB\_ERROR\_SYNTAX] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE rowid = 1’ at line 1

---

<div class="post-metadata">

**Author:** ![ksar](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/ksar/32/514_2.png) [@ksar](https://www.dolibarr.org/forum/u/ksar)\
**Post date:** [January 18, 2021, 10:43am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/6 "2021-01-18T10:43:28Z")

</div>

Yes I know, and you keep repeating the same thing since 3 posts.  
And I repeat my :

> [@ksar](#):
>
> see the complete SQL request syntaxe to understand what is the issue.

---

<div class="post-metadata">

**Author:** ![macky](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/m/df788c/32.png) [@macky](https://www.dolibarr.org/forum/u/macky)\
**Post date:** [January 18, 2021, 10:45am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/7 "2021-01-18T10:45:39Z")

</div>

okay will check . dont understand why it becomes error. hmmmm so far my code is okay

---

<div class="post-metadata">

**Author:** ![macky](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/m/df788c/32.png) [@macky](https://www.dolibarr.org/forum/u/macky)\
**Post date:** [January 18, 2021, 10:49am UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/8 "2021-01-18T10:49:04Z")

</div>

I also add a space in WHERE and it throws an error

---

<div class="post-metadata">

**Author:** ![Ghonz](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/g/9dc877/32.png) [@Ghonz](https://www.dolibarr.org/forum/u/Ghonz)\
**Post date:** [September 27, 2023, 1:29pm UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/9 "2023-09-27T13:29:57Z")

</div>

hello i got the same error when trying to delete an excess paid saved as available discount, here is the debug  
`UPDATE llx_facture_fourn set paye=0, fk_statut=1 WHERE (type IN (2,3) AND rowid = 187` 2.46[DB\_ERROR\_SYNTAX] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘’ at line 1

---

<div class="post-metadata">

**Author:** ![thamir123](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/t/7ea924/32.png) [@thamir123](https://www.dolibarr.org/forum/u/thamir123)\
**Post date:** [October 1, 2023, 7:24pm UTC](https://www.dolibarr.org/forum/t/you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-where-rowid-1-at-line-1/20111/10 "2023-10-01T19:24:39Z")

</div>

i have same problem

 ![image](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/6/6c0d2c8d7ca1d05c81b40c542a608fbacea751a6.png)
