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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:00:43+00:00 2026-05-28T14:00:43+00:00

i am referring to answer to my question , answer was provided by @abhy,

  • 0

i am referring to answer to my question , answer was provided by @abhy, that worked, the link is php proDOM parsing error

i am further working on it and want to save the extracted data into mysql database…

the code i am using is

 ?php
$ch = curl_init(); // create a new cURL resource
$word = 'books';
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://images.google.com/images?q=".$word."s&tbm=isch/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$data = curl_exec($ch); // grab URL and pass it to the browser
curl_close($ch); 

$dom = new DOMDocument();
@$dom->loadHTML($data); // avoid warnings

$listA = $dom->getElementsByTagName('a'); // read all <a> elements
foreach ($listA as $itemA) { // loop through each <a> element
    if ($itemA->hasAttribute('href')) { // check if it has an 'href' attribute
        $href = $itemA->getAttribute('href'); // read the value of 'href'
        if (preg_match('/^\/imgres\?/', $href)) { // check that 'href' should begin with "/imgres?"
            $qryString = substr($href, strpos($href, '?') + 1);
            parse_str($qryString, $arrHref); // read the query parameters from 'href' URI
        echo '<br>' . $arrHref['imgurl'] . '<br>';
    $sql = "INSERT INTO `p_url_imgsrch`(`id`, `word_id`, `url_imgsrch`) VALUES ('','8','$arrHref['imgurl']')";

    mysql_query($sql) or die("error in updating urls") ;

        }
    }
}


?>

the idea is, i will insert each link in database, extracted from parsing, i am sure that my connection is okay, the same mysql query string with dummy data is working in mysql and inserting data successfully. however i use dummy url in place of '$arrHref['imgurl']'..

the error i get is

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in
D:\wamp\www\demo\login\abhay.php on line 24

abhay.php is the file having this code, also, when trying to resolve the issue, sometime error was something like T_STRING …

where i am doing the blunder? kindly give me a guideline..

thanks

  • 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-28T14:00:44+00:00Added an answer on May 28, 2026 at 2:00 pm

    You could use "{$arrHref['imgurl']}" so php knows that this is a variable
    and you should not insert id if you want it to be auto incremented:

    $sql = "INSERT INTO `p_url_imgsrch`(`word_id`, `url_imgsrch`) VALUES ('8','{$arrHref['imgurl']}')"; 
    

    However this might cause a corrupt sql command as soon as $arrHref[‘imgurl’] contains a single quote.

    So a better solution would be to use mysql_real_escape_string:

    $imgurl = mysql_real_escape_string($arrHref['imgurl']);
    
    $sql = "INSERT INTO `p_url_imgsrch`(`word_id`, `url_imgsrch`) VALUES ('8','{$imgurl}')"; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Referring second answer to question: How to convert from ASCII to Hex and vice
Referring to this question, no solution/answer was given for Oracle platform. Selecting Nth Record
Referring to the first answer about python's bound and unbound methods here, I have
Referring to this question , how can i get the current page size in
referring to this question , I've decided to duplicate the tables every year, creating
I want to redirect users that arrive at my root url to another page
I have a feeling I may already know the answer to this question, but
Please note that I'm referring to 3-layer (logical layering) and not 3-tier (physical). Also
int i,j; std::string s; std::cin>>i>>j>>s>>s>>i; std::cout<<i<< <<j<< <<s<< <<i; Question Referring to the sample
I have an small question I didn't found an answer yet: how do I

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.