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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:59:01+00:00 2026-05-20T18:59:01+00:00

All the data is being passed as I have sufficiently tested over and over

  • 0

All the data is being passed as I have sufficiently tested over and over to ensure it is complete. The problem I am having is with my INSERT statement:

<?php
$db_name = "db";
$connection = mysql_connect('localhost','root','') or die(mysql_error());
$db = mysql_select_db($db_name,$connection) or die(mysql_error());
$sql = "INSERT INTO badges        (id,company_name,company_address,company_city,company_state,company_zip, badge_name,   badge_title) VALUES ";
for($i = 0; $i < count($_POST['badge_name']); $i++) {
$sql = "(
$_SESSION[company_name],
$_SESSION[company_address],
$_SESSION[company_city],    
$_SESSION[company_state],
$_SESSION[company_zip],
".$_POST['badge_name'][$i].",
".$_POST['badge_title'][$i].")";}
$result = mysql_query($sql) or die(mysql_error());
echo print_r($sql);
?>

And my $sql print_r() is:

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 'Test Company Name, 1224 Adams Ave, Portland,  Oregon, 97128, Bill Smith, W' at line 2

No data is being inserted in my table. I have verified and tested user/pass etc. All working OK.

For good measure, here is my array output showing ALL data is passed as expected.

Mike Jones
Owner
Test Company Name
1224 Adams Ave
Portland
Oregon
97128

Bill Smith
Worker
Test Company Name
1224 Adams Ave
Portland
Oregon
97128

I think I am missing something stupid simple here, but just been on this for 4-5 hours starting to go nuts! Thanks for any insight as to my ignorance!

Here is my table dump for any reference:

CREATE TABLE IF NOT EXISTS `badges` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`company_name` varchar(255) NOT NULL,
`company_address` varchar(255) NOT NULL,
`company_city` varchar(100) NOT NULL,
`company_state` varchar(25) NOT NULL,
`company_zip` varchar(12) NOT NULL,
`badge_name` varchar(100) NOT NULL,
`badge_title` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  • 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-05-20T18:59:02+00:00Added an answer on May 20, 2026 at 6:59 pm

    this will work, note the sql concat , for multiple inserts

        <?php 
    function cleanit($input){
        return mysql_real_escape_string(preg_replace('/[^a-zA-Z0-9\?.,_ -]/s', '', $input));
    }
            $db_name = "db";
            $connection = mysql_connect('localhost','root','') or die(mysql_error());
            $db = mysql_select_db($db_name,$connection) or die(mysql_error());
            $sql = "INSERT INTO badges (id,company_name,company_address,company_city,company_state,company_zip, badge_name, badge_title) VALUES ";
            for($i = 0; $i <= count($_POST['badge_name']); $i++) {
    
    
            $sql .= '("","'.cleanit($_SESSION['company_name']).'",
            "'.cleanit($_SESSION['company_address']).'",
            "'.cleanit($_SESSION['company_city']).'",    
            "'.cleanit($_SESSION['company_state']).'",
            "'.cleanit($_SESSION['company_zip']).'",
            "'.cleanit($_POST['badge_name'][$i]).'",
            "'.cleanit($_POST['badge_title'][$i]).'")';
            if($i<count($_POST['badge_name'])){$sql .=',';}
         }
            $result = mysql_query($sql) or die(mysql_error());
            echo print_r($sql);
            ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# Application I am creating that stores all data in SQL
I would like to wipe out all data for a specific kind in Google
I would like to force svcutil to generate all data contracts in an assembly
In my code, I want to view all data from a CSV in table
The question gives all necessary data: what is an efficient algorithm to generate a
How can I get a DataSet with all the data from a SQL Express
I'm looking for a listing of all MySQL data types and the available settings
Is there a relatively simple way to change all the data in a JTable?
We recently were given a client requirement to encrypt all their data while at
Is there a list describing all of the data_type parameters you can use in

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.