Solved

MYSQL simple update statement

Posted on 2016-11-01
3
51 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 50

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 109

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

Gigs: Get Your Project Delivered by an Expert

Select from 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

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

813 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

8 Experts available now in Live!

Get 1:1 Help Now