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

  • Home
  • SEARCH
  • 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 8858517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:50:51+00:00 2026-06-14T14:50:51+00:00

im having syntax errors thrown back at me when using mysqli_real_escape_string. The IDE that

  • 0

im having syntax errors thrown back at me when using mysqli_real_escape_string. The IDE that i am using shows no syntax issues, however this is the first time i have tried using this function with multiple CASE statements (infact i have not used this function very much at all).

The insertion code is here:

$query = "INSERT INTO `auctionwp_categories` 
         (`CategoryID`, `CategoryLevel`, `CategoryName`, `CategoryParentID`, `LeafCategory`, `AutoPayEnabled`, `BestOfferEnabled`, `Expired`, `IntlAutosFixedCat`, `Virtual`, `LSD`, `ORPA`)
  VALUES (
          '".mysqli_real_escape_string($link, $xmlCategoryID)."', '".mysqli_real_escape_string($link, $xmlCategoryLevel).", '".mysqli_real_escape_string($link, $xmlCategoryName).", '".mysqli_real_escape_string($link, $xmlCategoryParentID).",
          CASE '".mysqli_real_escape_string($link, $xmlLeafCategory)."' WHEN 'true' THEN 1 ELSE 0 END,
          CASE '".mysqli_real_escape_string($link, $xmlAutoPayEnabled)."' WHEN 'true' THEN 1 ELSE 0 END,
          CASE '".mysqli_real_escape_string($link, $xmlExpired)."' WHEN 'true' THEN 1 ELSE 0 END,
          CASE '".mysqli_real_escape_string($link, $xmlBestOfferEnabled)."' WHEN 'true' THEN 1 ELSE 0 END,
          CASE '".mysqli_real_escape_string($link, $xmlIntlAutosFixedCat)."' WHEN 'true' THEN 1 ELSE 0 END,
          CASE '".mysqli_real_escape_string($link, $xmlVirtual)."' WHEN 'true' THEN 1 ELSE 0 END,
          CASE '".mysqli_real_escape_string($link, $xmlLSD)."' WHEN 'true' THEN 1 ELSE 0 END,
          CASE '".mysqli_real_escape_string($link, $xmlORPA)."' WHEN 'true' THEN 1 ELSE 0 END
          )";

if (mysqli_query($link, $query)) {
echo "Successfully inserted " . mysqli_affected_rows($link) . " row";
} else {
echo "Error occurred: " . mysqli_error($link);
}

Connection to db is successfull via this code in a config file:

$user="root";
$pass="";
$database="auctionwp";
$server="localhost";

$link = mysqli_connect($server, $user, $pass, $database);

if (!$link) {
die('Connect Error (' . mysqli_connect_errno() . ') '
        . mysqli_connect_error());
}

echo 'Success... ' . mysqli_get_host_info($link) . "\n";

Is my problem of syntax due to the CASE statements? i can find no examples online or in php manual that show mysqli_real_escape_string being used on insertion with this statement,

regards
Martin

  • 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-14T14:50:52+00:00Added an answer on June 14, 2026 at 2:50 pm

    Thanks for your reply, before i had chance to see that someone had replied i managed to get it working keeping the CASE statements intact, it was actually quite easy once i got my head around it.
    What i did was this:

    // escape the returned values
    $xmlCategoryName = mysqli_real_escape_string($link, $xmlCategoryName);
    $xmlLeafCategory = mysqli_real_escape_string($link, $xmlLeafCategory);
    $xmlBestOfferEnabled = mysqli_real_escape_string($link, $xmlBestOfferEnabled);
    $xmlAutoPayEnabled = mysqli_real_escape_string($link, $xmlAutoPayEnabled);
    $xmlExpired = mysqli_real_escape_string($link, $xmlExpired);
    $xmlIntlAutosFixedCat = mysqli_real_escape_string($link, $xmlIntlAutosFixedCat);
    $xmlVirtual = mysqli_real_escape_string($link, $xmlVirtual);
    $xmlLSD = mysqli_real_escape_string($link, $xmllSD);
    $xmlORPA = mysqli_real_escape_string($link, $xmlORPA);
    
    
    // the insert query for the values
    $query = "INSERT INTO `auctionwp_categories` 
             (`CategoryID`, `CategoryLevel`, `CategoryName`, `CategoryParentID`, `LeafCategory`, `AutoPayEnabled`, `BestOfferEnabled`, `Expired`, `IntlAutosFixedCat`, `Virtual`, `LSD`, `ORPA`)
      VALUES (
              '".$xmlCategoryID."', '".$xmlCategoryLevel."', '".$xmlCategoryName."', '".$xmlCategoryParentID."',
              CASE '$xmlLeafCategory' WHEN 'true' THEN 1 ELSE 0 END,
              CASE '$xmlAutoPayEnabled' WHEN 'true' THEN 1 ELSE 0 END,
              CASE '$xmlExpired' WHEN 'true' THEN 1 ELSE 0 END,
              CASE '$xmlBestOfferEnabled' WHEN 'true' THEN 1 ELSE 0 END,
              CASE '$xmlIntlAutosFixedCat' WHEN 'true' THEN 1 ELSE 0 END,
              CASE '$xmlVirtual' WHEN 'true' THEN 1 ELSE 0 END,
              CASE '$xmlLSD' WHEN 'true' THEN 1 ELSE 0 END,
              CASE '$xmlORPA' WHEN 'true' THEN 1 ELSE 0 END
              )";
    

    All seems to be working right now as required.

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

Sidebar

Related Questions

I am having hard time digesting this syntax: void* operator new[](std::size_t, const std::nothrow_t&) throw();
I think know how to do this in C# but I'm having syntax trouble
Im having some trouble getting the syntax right. I have a movie clip that
Hello I am having syntax issues here completely confused on how to properly do
When having errors in my queries, the exception which is thrown by Symfony2 is,
I'm having troubles with a syntax error when trying to create a function in
I am having trouble with array_push. It is displaying Parse error: syntax error, unexpected
I'm having trouble finding the right syntax to replace an array of objects nested
I'm having a solr query syntax issue (I think) with solr 1.4. I'm trying
I'm having problems getting my rsync syntax right and I'm wondering if my scenario

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.