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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:43:59+00:00 2026-05-25T03:43:59+00:00

This is really, really weird. Basically, I have a MySQL syntax error occurring because

  • 0

This is really, really weird.

Basically, I have a MySQL syntax error occurring because of quotes in this string:

('Justin Bieber', '12312688'
 , 'http://a2.twimg.com/profile_images/1468693614/Inkwell_normal.jpeg', '0'),
('Nicki Minaj', '5422852'
 , 'http://a1.twimg.com/profile_images/1520039676/325789956_normal.jpg', '1'),
('Drizzy Drake', '2989144'
 ,'http://a0.twimg.com/profile_images/1483569177/drake-toronto_normal.jpg', '7'),
('Lil Wayne WEEZY F', '3058376'
 ,'http://a1.twimg.com/profile_images/712863751/lil-wayne-gq-2_normal.jpg', '6'),
('Kanye West', '4176631'
 ,'http://a3.twimg.com/profile_images/1132696610/securedownload_normal.jpeg', '4'),
('Wiz Khalifa', '2846894'
 ,'http://a3.twimg.com/profile_images/1400724773/5fa42d61-2b5e-4b12-ac9f-4e673c97ef16_8_normal.jpg', '8'),
('Beyonce Knowles', '1607181'
 ,'http://a1.twimg.com/profile_images/140949372/Beyonce_64_normal.jpg', '9'),
('KELENDRIA ROWLAND', '1214446'
 ,'http://a1.twimg.com/profile_images/1418081050/KELLY_ROWLAND_cover_8181v2_normal.jpg', '10'),
('Lupe Fiasco', '819343'
 ,'http://a2.twimg.com/profile_images/1450626759/209893_10150145920132282_8128837281_6973183_7422817_o_normal.jpg', '11'),
('Tinie Tempah', '761045'
 ,'http://a0.twimg.com/profile_images/1315150186/Tinie_Black_Jacket_Pic_normal.jpg', '13'),
('50cent', '4918067'
 ,'http://a3.twimg.com/profile_images/1508833809/street-king-energy_normal.png', '2'),
('TRINA ', '796672'
 ,'http://a1.twimg.com/profile_images/1441338027/Trina4372_normal.jpg', '12'),
('iamdiddy', '4012130'
 ,'http://a1.twimg.com/profile_images/1299211308/OG_FADER_FORT_DAY_4_19_normal.jpg', '5'),
('mediatemple', 
 '('Justin Bieber', '12312688'
   ,'http://a2.twimg.com/profile_images/1468693614/Inkwell_normal.jpeg', '0')'
   ,'http://a2.twimg.com/profile_images/421686554/mt-125x125-dk__d5d6295_normal.jpg', '14'),
  ('Chris Brown ', '4284795'
   ,'http://a2.twimg.com/profile_images/1515163027/image_normal.jpg', '3')

More specifically this portion, of which the Justin Bieber related part shouldn’t be there:

('mediatemple', 
 '('Justin Bieber', '12312688'
   ,'http://a2.twimg.com/profile_images/1468693614/Inkwell_normal.jpeg', '0')'
   ,'http://a2.twimg.com/profile_images/421686554/mt-125x125-dk__d5d6295_normal.jpg', '14')

Here’s my actual code:

$screennames = array(
                 0 => "JustinBieber",
                 1 => "NickiMinaj",
                 2 => "drakkardnoir",
                 3 => "LilTunechi",
                 4 => "kanyewest",
                 5 => "RealWizKhalifa",
                 6 => "beyonce",
                 7 => "KELLYROWLAND",
                 8 => "LupeFiasco",
                 9 => "TinieTempah",
                 10 => "50cent",
                 11 => "TRINArockstarr",
                 12 => "iamdiddy",
                 13 => "mediatemple",
                 14 => "chrisbrown"
                     );

for($i = 0; $i < 15; $i++) {
$xml[$i] = @simplexml_load_file('http://api.twitter.com/1/users/show.xml?screen_name=' . $screennames[$i]);
$name[$i] = $xml[$i]->name;
$followers[$i] = $xml[$i]->followers_count;
$imageurl[$i] = $xml[$i]->profile_image_url;
}

$rank=-1;

arsort($followers, SORT_NUMERIC); 
foreach ($followers as $key=>$value) {
    $rank++;
  $ranks[$key]=$rank;
}

for($i = 0; $i < 15; $i++) {
    $value[$i] = "('".$name[$i]."', '".$followers[$i]."', '".$imageurl[$i]."', '".$ranks[$i]."')";
}
for($i = 0; $i < 14; $i++) {
    $value_string .= $value[$i].",";
}

$value_string .=$value[14];

For reference, it queries the Twitter API, retrieves specific data about each $screenname value, then concatenates it into one big string for (...) VALUES $value_string, however on $value[13] it seems to just place $value[1] right in the middle of it.

So far I’ve tried;

Using implode (which always returns a function error).

Just using $value_string .=$value[$i]."," in the first for loop which leaves a trailing ,.

Changing $screennames values around.

I just don’t understand what could be causing this issue.

Any help/answers/comments would be very, very, very much appreciated :)!!

UPDATE 1

Here’s the final portion of my code, for good measure:

include("db_conn.php");
$conn = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($db_name) or die(mysql_error());

$query = "INSERT INTO twitter (name, followers, imageurl, rank) VALUES $value_string";
$result = mysql_query($query) or die(mysql_error());
mysql_close($conn);
  • 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-25T03:43:59+00:00Added an answer on May 25, 2026 at 3:43 am

    fixed:

    replace from first for loop down

    for($i = 0; $i < 15; $i++) {
       $value_string .="('".$name[$i]."', '".$followers[$i]."', '".$imageurl[$i]."', '".$ranks[$i]."'),";
    }
    
    $value_string=rtrim($value_string,",");
    echo $value_string;
    

    also removes the 2nd for loop which is rather pointless.

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

Sidebar

Related Questions

I have this really weird problem with my MySQL table. After some time a
This is a really weird problem that I have been having. When I download
Ok, this is a really weird one. I have an MPI program, where each
I have this really weird bug. When I scroll down my table view, down
I have this really weird problem in my code (.Net Framework 3.5). So, in
We have this really weird problem in a Web Application when using ActiveRecord 2.0
im a newbie to flash,and i hav got this really weird problem.i have created
This is really weird, and I cannot see why this is happening. In the
Well this is a really weird issue, I really didn't find anything on this
Boy, this one is really weird. I expect the following code to print 1990,

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.