danyo
danyo

Reputation: 5846

updating multiple columns in php

I have the following query:

$sql="UPDATE streams SET name='$name', limit='$limit', desc='$desc' WHERE id='$id'";

when I run this I get the following error:

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 'limit='15', desc='dsfds' WHERE id='14'' at line 1

where am I going wrong? I have been trying different options but I am not really getting anywhere.

Upvotes: 0

Views: 162

Answers (2)

juergen d
juergen d

Reputation: 204766

You are using a lot of reserved SQL words as column names. escape them using `

$sql="UPDATE streams SET `name`='$name', `limit`='$limit', `desc`='$desc' WHERE id='$id'";

Upvotes: 1

silly
silly

Reputation: 7887

i think you have to escape your limit (and desc) column, its a reserved keyword

$sql="UPDATE streams SET `name`='$name', `limit`='$limit', `desc`='$desc' WHERE `id`='$id'";

Upvotes: 1

Related Questions