Jump to content

[SOLVED] syntax error, unexpected $end


Modernvox

Recommended Posts

Can someone please tell me why the hell I keep getting an unexpected $end error?

<?php

    function curlURL($url) { 
        $curl = curl_init(); 
        curl_setopt($curl, CURLOPT_URL, $url); 
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); 
        $output = curl_exec($curl); 
            return $output; 
    } 
     
   $curlResults = curlURL("http://southcoast.craigslist.org/sss/"); 
   $pattern = '#<a href="(/[a-z]{3}/\d{10}\.html)">#';
   preg_match_all( $pattern, $curlResults, $matches);

echo "<pre>\n";
echo "Links:\n\n";
foreach ($matches[1] as $link):
   echo "\t" . '<a href="' . $link . '" target="_BLANK">' . $link . '</a>' . "\n";
endforeach;
echo '</pre>';


echo file_get_contents("http://southcoast.craigslist.org".$link);
$pattern = '#<sale-\K[a-z0-9]+-\d+@craigslist\.org(?=>)#';  //This is the attempted match for the email
preg_match_all( $pattern, $matches);
foreach ($matches[0] as $address):
endforeach;
$dbx= mysql_connect("localhost", "root", "");   //include before any database implematation
if (!$dbx)
{
die('Could not connect: ' . mysql_error());
}

mysql_SELECT_db("Craigslist", $dbx);
mysql_Query("INSERT INTO addresses (sale_items)
VALUES ('$address');



mysql_close($dbx);

?> 

Link to comment
Share on other sites

You havnt closed the query at the end

 

<?php

    function curlURL($url) { 
        $curl = curl_init(); 
        curl_setopt($curl, CURLOPT_URL, $url); 
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); 
        $output = curl_exec($curl); 
            return $output; 
    } 
     
   $curlResults = curlURL("http://southcoast.craigslist.org/sss/"); 
   $pattern = '#<a href="(/[a-z]{3}/\d{10}\.html)">#';
   preg_match_all( $pattern, $curlResults, $matches);

echo "<pre>\n";
echo "Links:\n\n";
foreach ($matches[1] as $link):
   echo "\t" . '<a href="' . $link . '" target="_BLANK">' . $link . '</a>' . "\n";
endforeach;
echo '</pre>';


echo file_get_contents("http://southcoast.craigslist.org".$link);
$pattern = '#<sale-\K[a-z0-9]+-\d+@craigslist\.org(?=>)#';  //This is the attempted match for the email
preg_match_all( $pattern, $matches);
foreach ($matches[0] as $address):
endforeach;
$dbx= mysql_connect("localhost", "root", "");   //include before any database implematation
if (!$dbx)
{
die('Could not connect: ' . mysql_error());
}

mysql_SELECT_db("Craigslist", $dbx);
mysql_Query("INSERT INTO addresses (sale_items)
VALUES ('$address')");



mysql_close($dbx);

?> 

 

Stuie

Link to comment
Share on other sites

You havnt closed the query at the end

 

<?php

    function curlURL($url) { 
        $curl = curl_init(); 
        curl_setopt($curl, CURLOPT_URL, $url); 
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); 
        $output = curl_exec($curl); 
            return $output; 
    } 
     
   $curlResults = curlURL("http://southcoast.craigslist.org/sss/"); 
   $pattern = '#<a href="(/[a-z]{3}/\d{10}\.html)">#';
   preg_match_all( $pattern, $curlResults, $matches);

echo "<pre>\n";
echo "Links:\n\n";
foreach ($matches[1] as $link):
   echo "\t" . '<a href="' . $link . '" target="_BLANK">' . $link . '</a>' . "\n";
endforeach;
echo '</pre>';


echo file_get_contents("http://southcoast.craigslist.org".$link);
$pattern = '#<sale-\K[a-z0-9]+-\d+@craigslist\.org(?=>)#';  //This is the attempted match for the email
preg_match_all( $pattern, $matches);
foreach ($matches[0] as $address):
endforeach;
$dbx= mysql_connect("localhost", "root", "");   //include before any database implematation
if (!$dbx)
{
die('Could not connect: ' . mysql_error());
}

mysql_SELECT_db("Craigslist", $dbx);
mysql_Query("INSERT INTO addresses (sale_items)
VALUES ('$address')");



mysql_close($dbx);

?> 

 

Stuie

 

:D Thank You!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.