Solved

MYSQL simple update statement

Posted on 2016-11-01
3
32 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 16

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 49

Assisted Solution

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

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

Open in new window

0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 250 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now