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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:32:39+00:00 2026-05-16T16:32:39+00:00

Ive been struggling to get my data to insert into my table. The data

  • 0

Ive been struggling to get my data to insert into my table. The data is pulled from an xml file into an array and echo’ing the results are fine but it fails on insertion.

 $dbhost = 'XXXX';
 $dbuser = 'XXXX';
 $dbpass = 'XXXX';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

if($conn)
 {
echo "Database Connection Successfull...<br /><br />";
 }

$dbname = 'a4027212_footy';
mysql_select_db($dbname) or die('Couldnt connect to database table');

if($dbname)
{
echo "Database ".$dbname." Selected..<br /><br />";
}

  $tweetmeme = "http://api.tweetmeme.com/stories/popular.xml?category=sports-soccer&count=30" ; 

  $xml = @simplexml_load_file($tweetmeme) or die ("no file loaded") ; 
  if($xml)
  {
echo "Tweetmeme XML loaded with ".count($xml->stories->story)." stories in the file..<br /><br />";
  }
 if(get_magic_quotes_gpc())
 {
echo "Magic Quotes is ON<br /><br />";
 }
foreach($xml->stories->story as $story)
{
    $title=$story->title;
$title=mysql_real_escape_string($title);

$url=$story->url;
$url=mysql_real_escape_string($url);

$media_type=$story->media_type;
$media_type=mysql_real_escape_string($media_type);

$created=$story->created_at;
$created=mysql_real_escape_string($created);


$url_count=$story->url_count;
$url_count=mysql_real_escape_string($url_count);

$comment_count=$story->comment_count;
$comment_count=mysql_real_escape_string($comment_count);

$excerpt=$story->excerpt;
$excerpt=mysql_real_escape_string($excerpt);

$sql = "INSERT INTO ft_tweets (title,url,media_type,created_at,mention_count,comment_count,excerpt) VALUES ($title,$url,$media_type,$created,$url_count,$comment_count,$excerpt)";

$result = mysql_query($sql) or die(mysql_error());
if($result)
{
echo "added to database<br />";
}
}
echo "<br /><br />";

ive been told that insertion will fail if there are special characters in the string and mysql_real_escape_string() would help but it hasnt. Ive tried with and without escaping to no avail.

the error message returned is: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 ‘off. Ankle looks bad here. on Twitpic),mysql_real_escape_string(http://twitpic.c‘ at line 1

and it fails on the sql insertion.

  • 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-16T16:32:39+00:00Added an answer on May 16, 2026 at 4:32 pm

    Right where that “off” begins is the character you’re having trouble with. I’d echo out the $sql first, followed by an quit(); command. Then, you’d see the missing quotes around the strings as Sabeen mentions.

    I also found this that references the server having magic quotes turned on:

    <?php
    function check_input($value)
    {
    // Stripslashes
    if (get_magic_quotes_gpc())
      {
      $value = stripslashes($value);
      }
    // Quote if not a number
    if (!is_numeric($value))
      {
      $value = "'" . mysql_real_escape_string($value) . "'";
      }
    return $value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been struggling coming up with a good solution to separate my testing data
I've been struggling with trying to get my commandButtons to perform an action (yet
I've been struggling all morning to get PIL installed on Cygwin. The errors I
I've been struggling for quite a while to get this feature working: I want
I've been struggling with a problem for the past couple days and haven't found
I've been struggling with this check constraint for a few hours and was hoping
I've been struggling with this one SQL query requirement today that I was wondering
I'd appreciate people's thoughts on a dilemma I've been struggling with ever since ASP.NET
This is a bit of a strange one, but I've been struggling for a
Ive been smashing my head with this for a while. I have 2 completely

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.