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 7806561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:34:30+00:00 2026-06-02T02:34:30+00:00

I have a query which runs fine if I manually declare $add to be

  • 0

I have a query which runs fine if I manually declare $add to be a value (30 for example) by when I try to set it to the user_id session the query fails.

// $add = 30;
// The line above works
$add = mysql_real_escape_string($_SESSION['user_id']);
$query = "UPDATE mytable SET act=0, add=$add WHERE id=$selected_user";

Any ideas where I’m going wrong.

  • 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-02T02:34:32+00:00Added an answer on June 2, 2026 at 2:34 am

    When using sessions you always need to specify this before any $_SESSION usage like this:

    session_start();
    //now you are able to use this
    $_SESSION['user_id'] = 30;
    

    By the other hand, I got the same problem as you before and what you need to do is to
    put the $_SESSION['user_id'] in a variable, then you will be able to pass it to the mysql_real_escape_string without problems.

    $id = $_SESSION['user_id'];
    //now use this:
    $add = mysql_real_escape_string($id);
    

    Hope this helps.

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

Sidebar

Related Questions

I have this query that runs fine: SELECT Value FROM data WHERE MetaDataID =
I have report1.jrxml which have simple SQL query with no parameters and runs fine
I have the following query which runs fine on all of my sql server
I have this sql query which runs fine when I execute it in MSSQL
I have an SQL LIKE query running on mySQL which runs fine on my
I have the following oracle query which runs fine SELECT c.customercode, s.sales_id FROM customers
I have a query which works fine in MySQL, but when I run it
I have a query which works fine var queryItems = rawQuery.ObsDataResultList.AsQueryable().Where(Name = @0 AND
I have stored procedure which runs perfectly. And when I insert it into query
Got the following simple query which works fine through phpmyadmin but when I add

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.