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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:52:59+00:00 2026-06-14T15:52:59+00:00

I have tried multiple times to insert into a database. The values contain a

  • 0

I have tried multiple times to insert into a database. The values contain a single quote – magic quotes are turned off, addslashes() and mysql_real_escape_string() both escape the characters but the script dies without adding to the database. I have also manually escaped but this failed as well. However, even removing the apostrophe, the script still dies.

The error is: Could not insert staff: 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 ’11, Hazel, Blonde, Has never missed a day of work, Graduated from Berkley, Serve’ at line 2
Anyone see any issues?

<?php
include('header.php');

$amount = 1;
$staffnum = '0101';
$height = array("5'11", "5'4", "6'2","5'5", "6'4");
$eye = array("Blue","Green","Hazel","Brown");
$hair = array("Brown", "Black", "Blonde", "Red");
$about1 = "Has never missed a day of work";
$about2 = "Graduated from Berkley";
$positions =  array('Server, Bartender', 'Bartender, Host', 'Sever, Host, Bartender', 'Cocktail Server, Bartender, Server'); 
$img = "none";
// arrays
$times = 1;


while($times <= 50) {
$staffnum ++; 
$heighta = mysql_real_escape_string($height[array_rand($height)]);
$eyea =  mysql_real_escape_string($eye[array_rand($eye)]);
$haira =  mysql_real_escape_string($hair[array_rand($hair)]);
$positionsa =   mysql_real_escape_string($positions[array_rand($positions)]);
$about1 =  mysql_real_escape_string($about1);
$about2 =   mysql_real_escape_string($about2);
$img =  mysql_real_escape_string($img);
$staffnum =  mysql_real_escape_string($staffnum);

$insert_staff = "INSERT INTO staff (staffnum, img_link, height, eye, hair, abt1, abt2, titles)
VALUES ($staffnum, $img, $heighta, $eyea, $haira, $about1, $about2, $positionsa)";

$insert_query = mysql_query($insert_staff);

if($insert_query) {
    ?>

<center>
  Member # <?php echo $staffnum; ?> has been added to the database.<br />
  <?php
} else {

  die('Could not insert staff: ' . mysql_error());

}

$times ++;
}

include('footer.php');
?>
  <a href="staff_insert.php?page=1">Return To Staff Insert</a>
</center>
  • 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-14T15:53:00+00:00Added an answer on June 14, 2026 at 3:53 pm

    You need to put quotes around the string variables you’re inserting:

    $insert_staff = "INSERT INTO staff (staffnum, img_link, height, eye, hair, abt1, abt2, titles)
    VALUES ('$staffnum', '$img', '$heighta', '$eyea', '$haira', '$about1', '$about2', '$positionsa')";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried multiple times. Can anybody tell me exact detailed steps? My mac
I know the title isn't very elaborate, but I have tried this multiple times
Im getting an error with my SQL queries in PHP. I have tried multiple
I have already tried multiple ways. defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME=YourNameHere;}' Also i've tried
I'm trying to import an XML file into a SQL Server database. Please have
I am having an issue while accessing single database instance using multiple/distributed Hibernate SessionFactories
I have to insert some records in a table in a legacy database and,
I have a function which is called multiple times during the program's execution. In
I've tried multiple times to install the Zen Coding plugin for Gedit in Ubuntu
Have tried to find solutions for this and can't really come up with anything.

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.