• 0

MySQL Update Unknown Query in WHERE Clause


Go to solution Solved by NJ Louch,

Question

generalt

I'm trying to run a query to update table xcodes. xcodes has two columns: codes and status. I want to update the status of the code contained in $code to 1.

 

$qu = "UPDATE xcodes SET status = 1 WHERE codes = $code";
$re = mysqli_query ($dbc, $qu) or trigger_error("Query: $qu\n<br/>MySQL Error: " . mysqli_error($dbc));

 

When I run the query, I get an error telling me that the code (in the variable $code) is an unknown column! The column is codes, not $code.

 

An error occurred on line 83: Query: UPDATE clickycodes SET status = 1 WHERE (codes = d24rg26p)
MySQL Error: Unknown column 'd24rg26p' in 'where clause'

 

I must have my syntax wrong. I've tried putting $code in brackets {$code} to no avail. What am I doing wrong?

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
NJ Louch

$qu = "UPDATE xcodes SET status = 1 WHERE codes = '$code'";

Link to post
Share on other sites
  • 0
generalt

Wow. I could have sworn I tried that.

 

Thanks!

Link to post
Share on other sites
  • 0
NJ Louch

It's always the simplest things we overlook. Now, next, within your PHP, use the PDO library and turn that into a stored procedure and pass it parameters :)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By News Staff
      Save 73% off the Interactive Learn to Code Bundle - now just $29.99
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 73% off the Interactive Learn to Code Bundle. Start writing codes and programs from scratch with 9 interactive courses on SQL, JavaScript, PHP, jQuery, BootStrap, and more.



      This deal consists of the following courses:

      An Interactive SQL Tutorial for Beginners: Introduction to SQL
      Getting Started with SQL Doesn't Have to Be Hard An Interactive JavaScript Course for Beginners
      Learn JavaScript Interactively with a One-of-a-Kind JS Online Course Interactive jQuery Tutorial: Learn jQuery Step-by-Step
      Take an Interactive jQuery Training Course for Beginners to Quickly Master jQuery Events, Effects & More Learn PHP Online: PHP Basics Explained in an Interactive & Fun Manner
      An Interactive Tutorial for Beginners Who Want to Master PHP Basics in a Non-Boring Way The Complete Solidity Smart Contract Guide
      Master Solidity Programming Through Hands-On Experience Master Python Fundamentals the Fun Way: An Interactive Python Tutorial
      A Python Training Course for Absolute Beginners Who Wants to Master the Language Without Getting Bored A Responsive Web Design Course: Find Out How to Create a Responsive Website
      Make a Website Mobile-Friendly with a Step by Step, Responsive Web Design Tutorial Bootstrap Tutorial: Learn to Create Dynamic Websites in a Pinch
      Find Out How to Use Bootstrap the Fun Way by Using an Interactive Course An Interactive Java Tutorial: Learn by Practice!
      Learn Java From Scratch by Combining Theory with Hands-On Coding Experience Good to know
      Length of time users can access this course: lifetime Certification of completion included Redemption deadline: redeem your code within 30 days of purchase For a full description, specs, and instructor info, click here.

      Here's the deal:
      This Interactive Learn to Code Bundle normally costs* $112, but you can pick it up for just $29.99 for a limited time - that represents a saving of $82.01 (73%) off.

      >> Get this deal, or learn more about it <<
      See all discounted Online Courses. This is a time-limited offer.
      Get $1 credit for every $25 spent · Give $10, Get $10 · 10% off for first-time buyers.

      Not for you?
      If this offer doesn't interest you, why not check out the following offers:

      The Nintendo Gaming Bundle Giveaway 20% off Ivacy VPN subscription with coupon code IVACY20 NordVPN subscription at up to 68% off for a 2 year plan Private Internet Access VPN subscription at up to 71% off Unlocator VPN or SmartDNS unblock Geoblock with 7-day free trial Disable Sponsored posts · Other recent deals · Preferred partner software

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs.

    • By Hamza Jawad
      Microsoft introduces Synapse Link and more to the Azure analytics space
      by Hamza Jawad



      At Build 2020 today, Microsoft unveiled an unprecedented, cloud-native implementation of hybrid transactional analytical processing (HTAP). Dubbed the Azure Synapse Link, the new capability allows for "immediate, in-the-moment insights on a business" without any additional burden on systems.

      The efficiency with which analytical data can be made available relies on an optimized columnar structure link with Synapse Analytics, as opposed to complex ETL pipelines. Currently available in Cosmos DB, Synapse Link is planned to be made available to Azure Database for PostgreSQL and Azure Database for MySQL in the future as well. Further announcements today regarding Azure Database offerings can be read in detail here.

      Other features introduced to Synapse Analytics in preview include "a unified experience with Synapse Studio, integrated SQL and Spark engines, serverless data lake exploration with Synapse SQL, shared metadata store and built-in Power BI authoring." More can be learned about these new capabilities here.



      In further news on Azure analytics and Storage, the Azure NetApp Files service is noted to have achieved "four-9s" or 99.99% availability. The milestone was reached back in February, and it brings the service to a state where it "meets requirements for most mission-critical applications".

      As far as Azure Database is concerned, Microsoft has also announced Azure SQL Edge in preview. Utilizing the SQL engine, the service is noted to help customers develop in a consistent area across a SQL database at the edge, or on-premise in the cloud. SQL Edge arrives with a small foot-print spanning less than 350mb of storage, and it can run on ARM- and x64-based devices regardless of connection availability.

    • By Hamza Jawad
      Azure Database offerings and Cosmos DB get a flurry of new capabilities
      by Hamza Jawad



      At its Build 2017 developer conference, Microsoft announced fully managed instances of MySQL and PostgreSQL on the Azure cloud platform, alongside a new NoSQL database, Cosmos DB. Kicking off this year's Build event, the tech giant has introduced a bunch of new capabilities for the aforementioned offerings.

      For starters, Cosmos DB now includes a "serverless" pricing model that aims to address the managing of small applications with fewer users. Pricing will be calculated based on a per-operation model in order to keep it cost-effective as a whole. Essentially, customers will be billed on the actual consumption of resources upon each database request.

      Moving on, enhanced data recovery options are now also being provided for mission-critical workloads, enabling such apps to do the following:

      And finally, Cosmos DB auto-scale provisioned throughput is now also generally available. The capability - previously termed autopilot - offers 99.999% guaranteed availability along with single-digit millisecond latency that leverages SLA. Auto-scaling based on customer-set provisioned throughputs means that customers do not need to manage scaling requirements themselves. Its full set of capabilities will become available in the summer.

      With regards to MySQL and PostgreSQL offerings in Azure Database, there are also a bunch of new capabilities. For the latter, logical decoding with wal2json is now in preview, while online migration for PostgreSQL Hyperscale using the Migration Service is now generally available. As far as the former is concerned, AD authentication, Private Link, and 3-year Reserved Instances Pricing have reached GA. Data encryption at rest with Customer Managed Keys will be making its way to users in June in the form of a preview.

      Microsoft has also highlighted its community contributions to PostgreSQL. These include:

      More information on the updated product capabilities can be found at Azure Database for PostgreSQL's documentation here, and MySQL's documentation here.

    • By News Staff
      SQL Commands for Beginners - Free cheat sheet download
      by Steven Parker

      Claim your complimentary free cheat sheet today, before the offer expires.



      What's it about?


      Look up SQL commands in a snap!

      SQL (Structured Query Language) is a handy tool for effective database management. If you’re new to SQL, the sheer number of commands you need to familiarize yourself with can prove to be a stumbling block. Thankfully, you can learn and recall SQL commands easily with this cheat sheet.

      Of course, the cheat sheet can prove just as helpful if you’re an SQL expert who needs a quick recap of the commands once in a while.

      Download today!

      How to get this free resource:
      Complete and verifiable information is required in order to receive this offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last! Please ensure you read the terms and conditions to claim this offer.

      >> SQL Commands for Beginners - Free cheat sheet download <<
      Offered by MakeUseOf, view their other free resources. Limited time offer.

      Not for you?
      That's OK, there are other free eBooks on offer you can check out here, but be aware that these are all time-limited offers. If you are uncomfortable sharing your details with a third-party sponsor, we understand. Or via our preferred partner:

      How can I disable these posts? Click here.

      Disclosure: A valid email address is required to fulfill your request. Complete and verifiable information is required in order to receive this offer. By submitting a request, your information is subject to TradePub.com's Privacy Policy.

    • By News Staff
      Save 97% off the 2020 Learn to Code Full Stack Developer Certification Bundle
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 97% off the 2020 Learn to Code Full Stack Developer Certification Bundle. Become a high-earning web developer with 50+ hours of instruction from top-tier instructors, including Rob Percival and John Elder.



      What's the deal?
      This deal consists of the following courses:

      Microsoft SQL Server & T-SQL Course For Beginners
      Understand the Benefits of SQL & Earn Big Bucks as a Skilled Developer Learn C# by Building Applications
      Understand the Concepts of C#6 &C#7 and Use Them to Build Real World .NET Console Apps Beginner Object-Oriented Programming in C# & .NET Core
      Climb Up the Developer Hierarchy by Mastering Object-Oriented Programming & Its Fundamental Concepts Using MySQL Databases with Python
      Learn MySQL Database with Python the Fast & Easy Way with John Elder HTML Programming for Everyone
      Learn to Build Awesome Websites Using HTML & the Bootstrap CSS Framework Intro to PHP for Web Development
      Learn PHP for Web Development & Become a Backend Coder in No Time The Complete C# Programming Course
      Master C# & .NET Framework with Code Challenges, Exercises, & Real-Life Examples with Rob Percival Advanced Python Training
      Go from Complete Beginner to a Python Language Expert Learn Angular by Creating a Web Application
      Master this Popular Web Dev Framework by Building an Interactive Virtual Cookbook Good to know
      Length of time users can access this course: lifetime Certification of completion included Redemption deadline: redeem your code within 30 days of purchase For a full description, specs, and instructor info, click here.

      What's the benefit?
      This 2020 Learn to Code Full Stack Developer Certification Bundle normally costs* $1,650, but you can pick it up for just $38.99 for a limited time - that represents a saving of $1,611.01 (97%) off.

      >> Get this deal, or learn more about it <<
      See all discounted Online Courses. This is a time-limited offer.

      Save even more!
      Stick with Neowin Deals and earn credit or even deeper discounts.

      Check out our recent deals here or on the Neowin Deals site. For every $25 spent, you get $1 credit added to your Neowin Deals account. Refer the deal for $10 credit via social media or email and if it results in a purchase of at least $10, you'll get $10 credit added to your account. 10% off for first-time buyers: be sure not to dismiss the popup offer to subscribe to email updates on the deals page in order to profit! Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerce's own determination of retail pricing.