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

  • Home
  • SEARCH
  • 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 9017761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:21:18+00:00 2026-06-16T04:21:18+00:00

I have built a php script that saves results from a hash tag search

  • 0

I have built a php script that saves results from a hash tag search and when I save the tweet ID it just tries saving a duplicate.
I have set a UNIQUE constraint on the table and it obviously doesn’t save anything but the first tweet and it throws the error below. Which isn’t surprising

ERROR: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147483647' for key 2

If I remove the constraint it saves all the tweets correctly but the tweet ID is duplicated

I have tried displaying the tweet in the output from the same variable I’m using to put in the table and it is all UNIQUE and correct so the variable is correct. So I can only assume some weirdness is going on all by itself

foreach($results as $result) {
$tweet_ID = $result->id_str;
$userID = $result->from_user_id_str;
$tweetText = $result->text;
$tweet_time = strtotime($result->created_at);
$createdAt = date('Y-m-d H:i:s ',$tweet_time);

echo '<div>'. $tweet_ID . 
     '<div class="tweet" >' . displayTweet($result->text),"\r\n" .
        '<div class="user">'. '<strong>Posted </strong>' . date('j/n/y H:i:s ',$tweet_time). '<strong> By </strong>' . 
        '<a rel="nofollow" href="http://twitter.com/' . $result->from_user. '">' . $result->from_user .
        '</div>' .
     '</div>';  

// Execute query 
$stmt = $conn->prepare("INSERT INTO ".$hashtag."(tweetID, userID, tweetText, createdAt) VALUES(:tweetID, :userID, :tweetText, :createdAt)");
$stmt->execute(array(':tweetID' => $tweet_ID, ':userID' => $userID, ':tweetText' => $tweetText, ':createdAt' => $createdAt));
}
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}

I can’t figure out for the life of me why it is saving some random numbers

The number that it is adding is 2147483647. Doesn’t mean anything to me.
Any help on what is going on would be appreciated

  • 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-16T04:21:19+00:00Added an answer on June 16, 2026 at 4:21 am

    This number 2147483647 clearly indicates that you are not using 64-bit integers to store tweet id. Tweet ids are 64-bit integers. You should use BIGINT data type for tweetID column.

    `tweetID` BIGINT UNSIGNED
    

    The special value you are getting 2147483647 is because all the upper bits are truncated when a 64-bit tweet id is cast to 32-bit signed int. If you could have use unsigned int The number would have been higher. But not more than 2147483647*2. Tweet ids are much higher than that. You have to use 64-bit unsigned int

    Also I see you are using a dynamic table name for your insert query. Dont do that! One single table can hold a lot of rows before you experience performance problem.

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

Sidebar

Related Questions

I have a directory that I've built with the PHP script below and it
I have a PHP application that is built around the MVC architecture without any
We have a cron'ed PHP script that checks an inbox every ten minutes. The
I have a PHP script that needs to be executed by the end of
I have a PHP built calendar that displays dates for each month. Now what
I have a form built dynamically by php script with a for/loop: <form id=formDay>
I'm using a script that's built on the YII framework. I just added an
I just started playing around with Phing build scripts (built with PHP). From what
I have a shell script that calls a php script to insert records in
I have a PHP script that processes my email subscriptions. It does something like:

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.