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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:52:39+00:00 2026-05-24T07:52:39+00:00

In my mysql database I get ONLY the records for id 26, 16, 17,

  • 0

In my mysql database I get ONLY the records for id 26, 16, 17, 18, 19, 22, 23, 24. Why is that, is there any error in my code? I don;t have a clue, please help:(

<?
$connect = mysql_connect('localhost', 'dbname', 'pass');  
if (!$connect) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("dbname") or die(mysql_error());

mysql_query("TRUNCATE TABLE anchors");

$blog_ids = array(
'anchor 1' => '1', 
'anchor 2' => '2', 
'anchor 3' => '3', 
'anchor 2' => '4',  
'anchor 2' => '5',  
'anchor 4' => '6',  
'anchor 5' => '7',  
'anchor 6' => '8', 
'anchor 7' => '9',  
'anchor 8' => '10', 
'anchor 9' => '13',
'anchor 10' => '14',
'anchor 11' => '16',
'anchor 12' => '17', 
'anchor 13' => '18', 
'anchor 14' => '20', 
'anchor 15' => '21', 
'anchor 16' => '22', 
'anchor 17' => '23', 
'anchor 18' => '24', 
'anchor 19' => '25', 
'anchor 20' => '26' 
);
foreach($blog_ids as $anchor => $blog_id){
$anchor_url = 'http://www.site.com';
mysql_query("INSERT INTO anchors (blog_id, anchor_url, anchor) VALUES ('$blog_id', '$anchor_url', '$anchor')");
} 

mysql_close($connect); 
?>

Ty very much, here is the table structure:

CREATE TABLE `anchors` (
 `id` int(11) NOT NULL auto_increment,
 `blog_id` text,
 `anchor_url` text,
 `anchor` text,
 PRIMARY KEY  (`id`),
 FULLTEXT KEY `posttitle` (`blog_id`,`anchor_url`,`anchor`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8
  • 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-24T07:52:40+00:00Added an answer on May 24, 2026 at 7:52 am

    Check whether the query actually can be executed.

    if (mysql_query("INSERT INTO anchors (blog_id, anchor_url, anchor) VALUES ('$blog_id', '$anchor_url', '$anchor')") === FALSE) {
        echo 'failed: ' . mysql_error() . "\n";
    }
    

    Furthermore, what is the table structure like? SHOW CREATE TABLE anchors; will help you. If you have a unique or primary key set, the value really needs to be unique and duplicates fail with an error.

    Edit: The problem is not within the script, but within the data. In order to have the data in PHP, the storage needs to be adjusted.

    $blog_ids = array(
      array(
        'anchor' => 'anchor 1',
        'blog_id' => '1'
      ),
      array(
        'anchor' => 'anchor 2',
        'blog_id' => '2'
      ),
      …
    );
    
    foreach ($blog_ids as $blog_id_array) {
      $blog_id = $blog_id_array['blog_id'];
      $anchor = $blog_id_array['anchor'];
      $anchor_url = 'http://www.site.com';
    
      if (mysql_query("INSERT INTO anchors (blog_id, anchor_url, anchor) VALUES ('$blog_id', '$anchor_url', '$anchor')") === FALSE) {
        echo 'failed: ' . mysql_error() . "\n";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add only unique records into a database table. Is there any
I have a mysql database called A. I would like to to get informations
I have some tables in a MySQL database to represent records from a sensor.
I have a MySQL 5 database that is updated every 5 minutes from a
What query should I execute in MySQL database to get a result containing partial
I've a php function to get some data from mysql database: function get_persons() {
How get data from mysql database? I use ASP.NET and C#.Previously, I used LINQ
How do I get my mysql database to return 0 if the neighborhood in
I want to get data from a table in my MySQL database. $linkID =
Is it possible to somehow get structure of MySQL database, or just some table

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.