Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8298249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:42:01+00:00 2026-06-08T15:42:01+00:00

I got this query that is not working, and I don’t know what it

  • 0

I got this query that is not working, and I don’t know what it is. I’m writing a email active scripts. This the URL;

http://www.example.com/activate.php?id=1&h=secretkey1

This is what activate.php looks like;

<?php
require "inc/connect.php";

$id = (int)$_GET['id'];
$hash = mysql_real_escape_string($_GET['h']);

$sql = mysql_query("SELECT id, h, active FROM tablename WHERE id=$id AND key=$hash") or die(mysql_error());  
$row = mysql_fetch_array($sql);

if ($row['active'] == "1") {
    echo "error!";
}
elseif ($row['active'] == "0") {
    mysql_query("UPDATE tablename SET active=1 WHERE id='$id' AND key='$hash'");
}
?>

This is the error that I get;

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ‘key=secretkey1’ at line 1

In my database I have a test field in tablename with;

id /    key    / active
------------------
1 / secretkey1 / 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:42:03+00:00Added an answer on June 8, 2026 at 3:42 pm

    Two reasons:

    1) Because you need to enclose secretkey1 (inside $hash) in single quotes, since it is a string and strings must be single-quoted. $id doesn’t need to be quoted since you have cast it to an integer.

    2) KEY is a MySQL reserved keyword, and must be enclosed in backquotes to be used as a table or column name:

    $sql = mysql_query("SELECT id, h, active FROM tablename WHERE id=$id AND `key`='$hash'") or die(mysql_error()); 
    

    I note also that you are selecting id, h, active in your query but your example table has a column named key, not h (unless we don’t see that column).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this query that works ok, select * from Materia where Cursar_Cursada=0 and
I got this error running a query that goes against 2 tables with combined
Right, so I've got a query that looks like this: $bestof_query = SELECT *
I've got a query that looks something like this: SELECT * FROM table WHERE
I've got a query that looks a bit like this: select records.id, contacts.name +
Hello I've got this query to get users by email, which is an unique
I got an email today saying: In every case that we have examined, this
i got this SQL query where post_title taken from $_GET $sql = SELECT ID
I got this Sql Query declare @ProductNo int set @ProductNo = 123 select o.OrderNo,
So I need to make 3 tabs with query (got this part down), but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.