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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:24:25+00:00 2026-06-04T10:24:25+00:00

I am using this function for my cURL queries. function get_source($url){ $ch = curl_init();

  • 0

I am using this function for my cURL queries.

function get_source($url){
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_HEADER, 0);
$source = curl_exec ($ch);
return $source;
}

The function works perfectly, but when I try to run it on a URL from my MySQL database, it wont work…

I have done the following tests…I am trying to get the source of a YouTube video:

Test 1:

echo get_source("http://www.youtube.com/watch?v=WxfZkMm3wcg");

**Result: Works, returns the source code of the video.**

Test 2:

$video="http://www.youtube.com/watch?v=WxfZkMm3wcg";
echo get_source($video);

**Result: Works, returns the source code of the video.** 

Test 3:

$video_arr=mysql_fetch_array(mysql_query("SELECT video FROM videos WHERE id='$video_id'")); 
$video=$video_arr['video'];
echo get_source($video);

**Result: Does not work. A blank string gets returned and there aren't any cURL errors that I can see...**

Test 4 (just to show my query is working)

$video_arr=mysql_fetch_array(mysql_query("SELECT video FROM videos WHERE id='$video_id'")); 
$video=$video_arr['video'];
var_dump($video);

**Result: string(38) "http://youtube.com/watch?v=WxfZkMm3wcg"**

I am not sure what to do or what is even going wrong. ANy suggestions?

  • 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-06-04T10:24:28+00:00Added an answer on June 4, 2026 at 10:24 am

    Try setting CURLOPT_FOLLOWLOCATION to true so the page can redirect if necessary.

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

Sidebar

Related Questions

function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data =
i have php function that parses a xml url and gives me an array.this
I am using Curl to download files from location function get_data($url) { $ch =
I'm using this code to get data using cURL $url='http://example.com/'; //URL to get content
I'm using system() PHP function to run some curl commands like this system(curl command
I am using this function to close existing form and open a new form.
I'm using this function to extract files from .zip archive and store it on
I am using this function https://www.php.net/sys_getloadavg to get a hint about my server load.
Dear all i am using this function to get the GMT time, i am
I'm using this function: preg_match_all('/((\d{9})\.html)/s', $content, $results); It works fine but i just want

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.