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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:09:09+00:00 2026-06-06T17:09:09+00:00

I have written PHP code which connects to MYSQL to look up information, sends

  • 0

I have written PHP code which connects to MYSQL to look up information, sends it to an API, and get a response to write back into a new table.

Sometimes it works perfectly, other times it doesn’t. When it doesn’t it gives me this error

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 ' , , '', '', '')' at line 1

or sometimes it will write one or two entries into the new table and then give me the error at a different line. Oh, and even if I choose the same data for the API to look up and send, sometimes it will work and sometimes it won’t.( I have taken all commas out of the strings that are being sent to cut back on possible errors with commas.)

I’m wondering if this is a problem with the API or my code. I can’t understand how it would work for some of the time, and be a problem on the code problem, which leads to my thoughts on possible API problems.

My hypotheses are:

  1. The API key I have has limited functionality and so limits my results.
  2. It takes to long for a response and so times out my request.

Do either of these make sense? Any other ideas?

Here’s the php code that sometimes gets back something:

Sometimes it will echo out. But othertimes it won’t. The function $request->whatever are available in the API functions php.

I believe the sql line that is throwing the error has to do with this:

insertRow($db, $new_table, $Merchant, $ips, $scoreBeforeGeo, $geoFactor, $scoreAfterGeo, $category, $overall_protocol, $protocol_name);

function insertRow($db, $new_table, $Merchant, $ips, $scoreBefore, $geoFactor,      $scoreAfter, $category, $overall, $protocol)
{
   $insert = "INSERT INTO $new_table " . " VALUES('$Merchant', '$ips', $scoreBefore, $geoFactor, $scoreAfter, '$category', '$overall', '$protocol');";
$q = mysqli_query($db, $insert) || die(mysqli_error($db));
}

Again, sometimes it works and sometimes it doesn’t….

  • 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-06T17:09:11+00:00Added an answer on June 6, 2026 at 5:09 pm

    Your code does not sanitize the input to the query or pass it via parameters. This means that if the data being passed into the INSERT statement has characters (such as apostrophes) that will be interpreted as SQL syntax, it will mess up your statement. It also has the potential to destroy or provide unintended access to your data. In other words, it is a SQL injection attack waiting to happen.

    Use prepared statements to guard against this. http://php.net/manual/en/mysqli.prepare.php

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

Sidebar

Related Questions

I have written a php code which will get one id from database and
I have written simple code to get content from xml file to php. $xml
I have written a PHP function to take a video embed code that has
I have written a simple code in page test_cookie.php to work with cookies. if(isset($_GET['data']))
Our website code is written in PHP. We have very little testing in regards
I have written a PHP application which requires storage of millions of integers between
I have a Facebook game titled Rails Across Europe. It is written in PHP/MySQL/Facebook
I have a web application written in PHP. It uses MySQL for data storage.
In one app, I have an administrative backend written in PHP, which allows to
I have written a web app in PHP which makes use of Ajax requests

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.