bores_escalovsk Posted May 7, 2014 Share Posted May 7, 2014 <?php $url = "http://www.something.com"; $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlresult = curl_exec ($curl); curl_close($curl); preg_match_all("/ something=something/", $curlresult, $theurls); $string = serialize($theurls); $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER2['HTTP_USER_AGENT']); curl_setopt ($curl, CURLOPT_URL, $string); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlresult2 = curl_exec ($curl); curl_close ($curl); print $curlresult2; ?> so im realy new to php and its probably a silly mistake .-. this is the answer i got from wamp syntax error, unexpected '$curl' (T_VARIABLE) anyway , can some one help me? Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/ Share on other sites More sharing options...
requinix Posted May 7, 2014 Share Posted May 7, 2014 There's nothing wrong with what you posted. What line had the problem? What editor are you using? Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478528 Share on other sites More sharing options...
r3wt Posted May 7, 2014 Share Posted May 7, 2014 remove the space in this line: before $curlresult2 = curl_exec ($curl); after $curlresult2 = curl_exec($curl); Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478530 Share on other sites More sharing options...
bores_escalovsk Posted May 7, 2014 Author Share Posted May 7, 2014 There's nothing wrong with what you posted. What line had the problem? What editor are you using? notepad++ remove the space in this line: before $curlresult2 = curl_exec ($curl); after $curlresult2 = curl_exec($curl); he hasnt there before hehehe but same error <?php $url = "http://www.site.com"; $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlresult = curl_exec ($curl); curl_close($curl); preg_match_all("/ imsmartasamonkey=\"(.*)\">(.*)<\/a><\/p>/", $curlresult, $theurls); $string = serialize($theurls); $curl = curl_init(); /*ERROR IS IN THIS LINE*/ curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER2['HTTP_USER_AGENT']); curl_setopt ($curl, CURLOPT_URL, $string); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlresult2 = curl_exec ($curl); curl_close ($curl); print $curlresult2; ?> Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478653 Share on other sites More sharing options...
requinix Posted May 7, 2014 Share Posted May 7, 2014 You might have some invisible badness near there. Shift+space sometimes creates non-breaking spaces, which PHP does not treat the same as regular spaces. Do you have the option to "show all characters" enabled? Turn it on and see if there's something unusual hiding around that line. Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478654 Share on other sites More sharing options...
bores_escalovsk Posted May 7, 2014 Author Share Posted May 7, 2014 (edited) the problem was solved by redoing the spaces and replacing the $SERVER2 with $SERVER , but now it shows nothing as result...the first Curl is getting multiple urls, i think i might need a foreach or something no ? i will try to clean the first Curl result <?php $url = "http://www.site.com"; $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlresult = curl_exec ($curl); curl_close($curl); preg_match_all("/ href=\"(.*)\">(.*)<\/a><\/p>/", $curlresult, $theurls); $string = serialize($theurls); $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt ($curl, CURLOPT_URL, $string); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlresult2 = curl_exec ($curl); curl_close ($curl); print $curlresult2; ?> Edited May 7, 2014 by bores_escalovsk Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478656 Share on other sites More sharing options...
Jacques1 Posted May 7, 2014 Share Posted May 7, 2014 I have absolutely no idea why you're trying to use serialize(). What do you expect this function to do? If you check the manual, you'll see that it creates a technical string representation of a value to be stored for later deserialization. That's not exactly helpful in your case. I also don't get why you throw away the first cURL instance and create a new one. What's wrong with the first one? Regarding multiple URLs, you want curl_multi_init(). Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478657 Share on other sites More sharing options...
bores_escalovsk Posted May 7, 2014 Author Share Posted May 7, 2014 I have absolutely no idea why you're trying to use serialize(). What do you expect this function to do? If you check the manual, you'll see that it creates a technical string representation of a value to be stored for later deserialization. That's not exactly helpful in your case. I also don't get why you throw away the first cURL instance and create a new one. What's wrong with the first one? Regarding multiple URLs, you want curl_multi_init(). thats my semi-monkey IQ hehe , thanks u realy helped . what i was trying to do is check a page of search(not google) and enter on each link of the search. kinda like a spider but with a filter. Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478658 Share on other sites More sharing options...
bores_escalovsk Posted May 7, 2014 Author Share Posted May 7, 2014 CURLOPT_FOLLOWLOCATION i think this is the command i needed anyway ,thanks for the help , how do i close the threat? Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478659 Share on other sites More sharing options...
Solution requinix Posted May 8, 2014 Solution Share Posted May 8, 2014 anyway ,thanks for the help , how do i close the threat?Find the most useful or informative reply and hit its Mark Solved button. Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478661 Share on other sites More sharing options...
Jacques1 Posted May 8, 2014 Share Posted May 8, 2014 Looks like this is easier said than done. Quote Link to comment https://forums.phpfreaks.com/topic/288301-syntax-error-unexpected-curl-t_variable/#findComment-1478683 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.