Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MYSQL simple update statement

Posted on 2016-11-01
3
Medium Priority
?
89 Views
Last Modified: 2016-11-01
what is wrong with my sql statement?
I use php and mysql
$id is an integer

$sql3 = "UPDATE urunler SET tavsiye='$tavsiye' WHERE id='$id'";

$result3 = $conn->query($sql3);
0
Comment
Question by:Braveheartli
3 Comments
 
LVL 17

Expert Comment

by:Chris Harte
ID: 41868235
You do not need the single quotes, that will change the variables into a string. Variables inside a double quote will parse into their value.

$sql3 = "UPDATE urunler SET tavsiye= $tavsiye WHERE id= $id";

$result3 = $conn->query($sql3);

Open in new window

0
 
LVL 54

Assisted Solution

by:Ryan Chong
Ryan Chong earned 1000 total points
ID: 41868238
tried this?

$sql3 = "UPDATE urunler SET tavsiye='$tavsiye' WHERE id=$id ";

Open in new window

0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1000 total points
ID: 41868240
There is nothing wrong with the statement.  The apostrophes will not hurt anything.  What is the error message you get from MySQL?

This article shows how to use MySQL and PHP together.  Many code examples are included.  Error checking is shown in all the examples!
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question