Solved

MYSQL simple update statement

Posted on 2016-11-01
3
77 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 52

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 110

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

630 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