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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:13:21+00:00 2026-05-15T02:13:21+00:00

I am trying to insert a lot of fields into a MySQL database, some

  • 0

I am trying to insert a lot of fields into a MySQL database, some are failing, so I am adding some code into my PHP script to try and track down what is occurring.

The replace seems to work as I can see the fields being populated in mysql, but I get this error:

1064: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 ‘1’ at line 1

//insert query
if (strlen($link_name)>0)
{
$query = mysql_query("REPLACE into jos_mt_links
(link_id, link_name, alias, link_desc, user_id, link_approved, metadesc, link_created, link_modified, website, price)
VALUES ('$link_id','$link_name','$link_name','$description','63','1','$metadesc','$link_created','$link_modified','$website','$cost')");
echo $link_name . "has been inserted <br />";
print "SQL-Query: ".$query."<br>";

    if(mysql_query($query,$db))
   {
    echo "<center><font face='$fonts' size=2 color='$green'>";
    echo " OK !</font><br><br>\n";
   }
  else
   {
    echo "<center><font face='$fonts' size=3 color='$red'>";
    echo "Error<br><br>";
       echo mysql_errno() . ":" . mysql_error() . "</font><br>\n";
   }
  • 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-15T02:13:22+00:00Added an answer on May 15, 2026 at 2:13 am

    There is nothing wrong with your SQL. You’re assigning $query to the result of your mysql_query() call:

    $query = mysql_query("REPLACE into jos_mt_links
        (link_id, link_name, alias, link_desc, user_id, link_approved, metadesc,
        link_created, link_modified, website, price)
        VALUES
        ('$link_id','$link_name','$link_name','$description','63','1','$metadesc','$link_created','$link_modified','$website','$cost')");
    

    mysql_query() returns true or false as a result of the REPLACE query, but the more important thing is that you’re assigning the result, not the SQL query that you’re executing.

    Furthermore, in here:

    if(mysql_query($query,$db))
    

    You’re calling mysql_query() again on the same $query variable which now holds a value of true (since you said your query is working and your database is being updated normally). PHP interprets boolean true as string '1' and you’re telling MySQL to run a query called 1, which gives that error.

    You probably meant to assign $query like this instead so your if condition works properly:

    $query = "REPLACE into jos_mt_links
        (link_id, link_name, alias, link_desc, user_id, link_approved, metadesc,
        link_created, link_modified, website, price)
        VALUES
        ('$link_id','$link_name','$link_name','$description','63','1','$metadesc','$link_created','$link_modified','$website','$cost')";
    

    And calling your echo within the if statement too.

    Another thing: as what Mark Baker has noted, please be sure your variables have been escaped with mysql_real_escape_string() before sticking them directly in your SQL like that.

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

Sidebar

Related Questions

Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get
I've got a typical problem when trying to insert a date into MySQL. The
I'm trying to run the code below to insert a whole lot of records
I'm trying to insert a clob into Oracle. If I try this with an
I'm trying to insert CLOB s into a database (see related question ). I
I am trying to create a new row to a database using insert into
I'm trying to create some triggers for my MySQL tables to keep track of
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
I'm trying to insert the current date/time to the database as the last time

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.