...

View Full Version : curl advice please?



LJackson
03-19-2010, 03:36 PM
Hi

I have a list of products which i am displaying on my site and im using an API to get the data like title, url, image etc but what i am trying to achieve is to get the trailers from the provided urls so for example

if i had the following url
http://www.play.com/DVD/DVD/4-/-/-/Product.html?title=10674623&source=9593

would it be possible to extract the trailer link and store it in a db table? and as i would be doing this with several products from play.com hopefully the taga would be the same so should be quite straight forward? and then display the trailer on a webpage on my site? would i need plays permission? im advertising play.com product through an affiliate agreement.

is there another way of doing this?

any help is appreciated
thanks
Luke

LJackson
03-19-2010, 03:46 PM
ok i have looked around and i have come up with this


<?php

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://www.play.com/DVD/DVD/4-/-/-/Product.html?title=10674623&source=9593');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

if (empty($buffer))
{
print "Error.<p>";
}
else
{
print $buffer;
}
?>

which when run loads up my example link which is great!

but now im not sure where to go from here to get just the trailer?

any help please
thanks

LJackson
03-19-2010, 03:59 PM
the video is within this code on there page

<div class="special slice"><ul><li><br><center><object type="application/x-shockwave-flash" width="403" height="298" id="playVideoPlayer" wmode="transparent" data="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/10674623.flv&vol=0.5&packShot=http://images.play.com/covers/10674623m.jpg" allowScriptAccess="always"><param name="movie" value="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/10674623.flv&vol=0.5&packShot=http://images.play.com/covers/10674623m.jpg" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><embed name="playVideoPlayer" src="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/10674623.flv&vol=0.5&packShot=http://images.play.com/covers/10674623m.jpg" loop="false" width="403" height="298" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></center><br><br></li><li> Behind the Scenes</li><li> Interviews with Cast and Crew</li></ul></div>

LJackson
03-19-2010, 04:27 PM
ok i now have this

<?php
include("dbinfo.php");

function storeLink($url,$gathered_from) {
$query = "INSERT INTO links (url, gathered_from) VALUES ('$url', '$gathered_from')";
mysql_query($query) or die('Error, insert query failed');
}

$target_url = "http://www.play.com/DVD/DVD/4-/-/-/Product.html?title=10674623&source=9593";
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';

// make the cURL request to $target_url
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
#curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$html= curl_exec($ch);
if (!$html) {
echo "<br />cURL error number:" .curl_errno($ch);
echo "<br />cURL error:" . curl_error($ch);
exit;
}

// parse the html into a DOMDocument
$dom = new DOMDocument();
@$dom->loadHTML($html);

// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body/center//object");

for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
storeLink($url,$target_url);
echo "<br />Link stored: $url";
}
?>

but this throws up an error on this line
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

which is why ive commented it out, but it does not insert anything into the db???

the error it throws out is

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set on line 17

any ideas
thanks
Luke

LJackson
03-20-2010, 01:58 AM
anyone have any ideas as to why this is not working???

thanks
Luke

MattF
03-20-2010, 02:14 AM
Are you just wanting to embed the video or actually download the flv file? This part of the link contains the name/id of the flv file, btw.

title=10674623

LJackson
03-20-2010, 02:17 AM
hi mate i want the code to embed it in to my site, i will take the object code and add it to my db table and then call that code to show the video on my site. just not sure where im going wrong with the curl, only just started using it today :)

thanks
Luke

MattF
03-20-2010, 02:21 AM
This will give you the link to the flv file:



$uri = 'http://www.play.com/DVD/DVD/4-/-/-/Product.html?title=10674623&source=9593';
preg_match('#title\=(\d+?)\&#', $uri, $match);
$link = 'http://media.play.com/ProductPage_Trailers/Films/'.$match[1].'.flv';


Just alter the $link var to contain the object code. You have the file id/name. No need for using curl or suchlike.

LJackson
03-20-2010, 02:25 AM
hi mate thanks for your reply,

firstly would this work with more than one url from the same website play.com for example if i wanted another video of another dvd would this work for it?

and secondly how does one show the video on my site?

sorry havent got a clue :(
thanks
Luke

p.s this is the code i was referring to


<object type="application/x-shockwave-flash" width="403" height="298" id="playVideoPlayer" wmode="transparent" data="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/10674623.flv&vol=0.5&packShot=http://images.play.com/covers/10674623m.jpg" allowScriptAccess="always"><param name="movie" value="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/10674623.flv&vol=0.5&packShot=http://images.play.com/covers/10674623m.jpg" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><embed name="playVideoPlayer" src="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/10674623.flv&vol=0.5&packShot=http://images.play.com/covers/10674623m.jpg" loop="false" width="403" height="298" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>


which when pasting in to a php page it displays the related video :)

cheers

MattF
03-20-2010, 02:31 AM
Try this on your testpage:



$uri = 'http://www.play.com/DVD/DVD/4-/-/-/Product.html?title=10674623&source=9593';
preg_match('#title\=(\d+?)\&#', $uri, $match);
$link = '<object type="application/x-shockwave-flash" width="403" height="298" id="playVideoPlayer" wmode="transparent" data="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$match[1].'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$match[1].'m.jpg" allowScriptAccess="always"><param name="movie" value="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$match[1].'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$match[1].'m.jpg" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><embed name="playVideoPlayer" src="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$match[1].'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$match[1].'m.jpg" loop="false" width="403" height="298" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>';

print($link);

LJackson
03-20-2010, 02:36 AM
hi mate yeah that works :)

loads the video fine, will try it with another product?

one moment....

LJackson
03-20-2010, 02:45 AM
ok using this url
http://www.play.com/DVD/Blu-ray/4-/-/-/Product.html?title=12089933&source=9593

it loads the player and images but wont play the video when you click on the play button? there are no errors or anything like that?

which is a bit strange.
cheers

LJackson
03-20-2010, 03:02 AM
it seems to work with other dvds but not other categories and the ony thing i can see that is different in the url is



http://www.play.com/DVD/Blu-ray/4-/-/-/Product.html?title=12090170&source=9593
http://www.play.com/DVD/DVD/4-/-/-/Product.html?title=10853630&source=9593


this bit /DVD/Blu-ray/ which seems to show the categoy of the product, would that break your preg_match? bearing in mind the firsh category could be Games as well

cheers mate

MattF
03-20-2010, 03:02 AM
Try this:



$uri = 'http://www.play.com/DVD/Blu-ray/4-/-/-/Product.html?title=12089933&source=9593';
$input = file_get_contents($uri);

if (preg_match('#/Films/(\w+?)\.flv\&#', $input, $match))
{
$link = '<object type="application/x-shockwave-flash" width="403" height="298" id="playVideoPlayer" wmode="transparent" data="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$match[1].'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$match[1].'m.jpg" allowScriptAccess="always"><param name="movie" value="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$match[1].'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$match[1].'m.jpg" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><embed name="playVideoPlayer" src="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$match[1].'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$match[1].'m.jpg" loop="false" width="403" height="298" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>';

print($link);
}

MattF
03-20-2010, 03:05 AM
it seems to work with other dvds but not other categories and the ony thing i can see that is different in the url is

There are some discrepancies between some of the links and some of the filenames. That code I've posted above will actually parse the page itself, so should hopefully work across the board.

LJackson
03-20-2010, 03:09 AM
unfortunatly the code above break it :( the product image no longer loads

cheers

LJackson
03-20-2010, 03:12 AM
i printed out the value of match[1] and i get this

10674623.flv

im assuming with your code the .flv should not be there?

cheers

MattF
03-20-2010, 03:15 AM
i printed out the value of match[1] and i get this

10674623.flv

im assuming with your code the .flv should not be there?

cheers

Bugger. :D I've updated my last code. Try that. If the images still aren't showing, their flenames will probably need gleaning from the uri, as in the original code. Try that updated code first though. (It's just the preg_match line which has been altered, btw).

LJackson
03-20-2010, 03:21 AM
YES!!!! it seems to be working, the dvd and blu-ray links now works fine :D havent tested with games but that should work.

thank you so much mate really appreciate it :)
your a star!!!!!

cheers mate!!!!!!!!!!!!!!

MattF
03-20-2010, 03:25 AM
You may need to alter the regex slightly for the games. I assume those files will probably be in a different directory. Post the link to one of the flv files if you have any probs with those.

LJackson
03-20-2010, 03:26 AM
will do mate thanks, will look in to that tomorrow, time for sleep :D

cheers

MattF
03-20-2010, 03:29 AM
time for sleep :D

I know that feeling all too well. :D It's something which oft eludes me though. :D

LJackson
03-22-2010, 11:00 PM
cant believe that i couldnt notice the other error with the to $url and $uri...

is there a way to get the video play automatically once opened? and is there a way to have the new window size set to the video size? as some of the videos are larger than others?

here is what i have on my main page

if($current_category['category'] == "DVD" && $row['merchName'] == "Play.com")
{
$url = $link;
$input = file_get_contents($url);

if (preg_match('#/Films/(\w+?)\.flv\&#', $input, $match))
{?>
<img id="listen<?php echo $counter?>" src="images/watchit.png" border="0" alt="View Trailer" title="View Trailer" style="visibility:hidden" onmouseover="this.style.cursor='pointer';" onclick="window.open('song_preview.php?id=<?php echo $row['ASIN']?>','Window1','menubar=no,width=356,height=300,toolbar=no,resize=no');" />
<script>document.getElementById("listen<?php echo $counter?>").style.visibility="visible";</script>
<?php }
}


if($current_category['category'] == "CD" && $row['ASIN'] <> "")
{?>
<img id="listen<?php echo $counter?>" src="images/listen.png" border="0" alt="Preview Tracks" title="Preview Songs" style="visibility:hidden" onmouseover="this.style.cursor='pointer';" onclick="window.open('song_preview.php?id=<?php echo $row['ASIN']?>','Window1','menubar=no,width=356,height=300,toolbar=no,resize=no');" />
<script>document.getElementById("listen<?php echo $counter?>").style.visibility="visible";</script>
<?php
}?>


and for the song_preview.php page i have

<?php
$find = "SELECT * FROM category_data3 WHERE ASIN = '$album'";
$query = mysql_query($find) or die(mysql_error());
while($row = mysql_fetch_array($query))
{
if ($row['category'] == "DVD")
{
switch($row['merchName'])
{
case "Play.com";
$link = '<object type="application/x-shockwave-flash" width="403" height="298" id="playVideoPlayer" wmode="transparent" data="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$album.'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$album.'m.jpg" allowScriptAccess="always"><param name="movie" value="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$album.'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$album.'m.jpg" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><embed name="playVideoPlayer" src="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$album.'.flv&vol=0.5&packShot=http://images.play.com/covers/'.$album.'m.jpg" loop="false" width="403" height="298" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>';
print $link;
}
}
elseif($row['category'] == "CD")
{?>
<script type='text/javascript'>
var amzn_wdgt={widget:'MP3Clips'};
amzn_wdgt.tag='kernconn-21';
amzn_wdgt.widgetType='ASINList';
amzn_wdgt.ASIN= '<?php echo $album?>';
amzn_wdgt.title='';
amzn_wdgt.width='336';
amzn_wdgt.height='280';
amzn_wdgt.shuffleTracks='False';
amzn_wdgt.marketPlace='GB';
</script>
<script type='text/javascript' src='http://wms.assoc-amazon.co.uk/20070822/GB/js/swfobject_1_5.js'>
</script><?php
}
}?>

if possible i would like the first code to start when loaded.

cheers
Luke

MattF
03-22-2010, 11:08 PM
cant believe that i couldnt notice the other error with the to $url and $uri...

We've all missed the blatantly obvious on occasion. You're not alone on that count by any means. :D

Check the available object params for an autoplay var, (if there is one), and set that to true.

LJackson
03-22-2010, 11:49 PM
have looked through the code but there isnt a param for autoStart so i've googled it and it says to add a autoStart=true after the .flv which i've done by it still wont autostart :(

maybe its just not ment to?

here is my current code

$link = '<object type="application/x-shockwave-flash" width="403" height="298" id="playVideoPlayer" wmode="transparent" data="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$album.'.flv&autoStart=true&vol=0.5&packShot=http://images.play.com/covers/'.$album.'m.jpg" allowScriptAccess="always"><param name="movie" value="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$album.'.flv&autoStart=true&vol=0.5&packShot=http://images.play.com/covers/'.$album.'m.jpg" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><embed name="playVideoPlayer" src="http://media.play.com/trailers/videoPlayer.swf?file=http://media.play.com/ProductPage_Trailers/Films/'.$album.'.flv&autoStart=true&vol=0.5&packShot=http://images.play.com/covers/'.$album.'m.jpg" loop="false" width="403" height="298" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>';
print $link;

MattF
03-23-2010, 12:15 AM
Try it with autoPlay instead.

LJackson
03-23-2010, 12:29 AM
unfortunatly still not autoplaying. its not a major thing but would of been nice :)

will keep scouring the web

MattF
03-23-2010, 01:15 AM
unfortunatly still not autoplaying. its not a major thing but would of been nice :)

will keep scouring the web

If you have some form of affiliation with the site, have you thought of just contacting them and asking if it's possible to do? If you're a recognised affiliate, they should be willing to discuss whether it's possible or not.


Btw, did that regex work for the different product sections?

LJackson
03-23-2010, 01:39 AM
thats a good idea mate, didnt think of that :)

re: regex i havn't tried it with video games but works for dvds and blurays will test it for video games...

MattF
03-23-2010, 01:54 AM
re: regex i havn't tried it with video games but works for dvds and blurays will test it for video games...

Let us know how it goes. I'm curious regarding whether it will need tweaking or not.

LJackson
03-23-2010, 02:36 AM
hi mate,

just tried it with a video game and unfortunatly it didnt work.

here is a video game product link

http://www.play.com/Games/Xbox360/4-/-/-/Product.html?title=8241124&source=9593

just a thought the above url could have several "versions" on for each platform PS3, Wii etc do you want all the platform names as they appear in the links?

cheers

MattF
03-23-2010, 02:46 AM
Try this:



if (preg_match('#/(?:Films|Games)/(\w+?)\.flv\&#', $input, $match))

LJackson
03-23-2010, 02:51 AM
interesting...

the dvds still work fine and im getting the image of the video games but the video wont play?

a bit strange

MattF
03-23-2010, 03:01 AM
You'll need a different link for the games, with GAMES instead of FILMS in the path. Try this test:



if (preg_match('#/(Films|Games)/(\w+?)\.flv\&#', $input, $match))
{
print($match[1]."\n".$match[2]."\n");
}


You should get the directory from $match[1] now, (instead of the .flv filename), and the flv name from $match[2].

LJackson
03-23-2010, 03:04 AM
hi mate yeah your correct the result of the above code is

Games 8241124

:)

MattF
03-23-2010, 03:04 AM
An example of how you would use that in your code now:



http://media.play.com/ProductPage_Trailers/'.$match[1].'/'.$match[2].'.flv

LJackson
03-23-2010, 03:14 AM
thats insane mate, thank you!!!!

LJackson
03-24-2010, 01:11 PM
Hi mate,

i am trying to pull a trailer from another site (thehut.com) with a url example of

http://www.thehut.com/dvd/new-moon-double-disc/10066512.html

the trouble im having with this is the flv file name has two different numbers, one is the one in the url but im not sure what the other one means or where to get it.

here is the file name

http://thehut.pantherssl.com/design-assets/trailers/10066512-20092910.flv

the second number changes for each product. ive searched the source code for some ideas as to where/what this number means but there is no other reference to it

looking more closley it seems to be a date, i thought maybe the release date but its not :(

would i need to use another way of getting this trailer?

thanks
Luke

MattF
03-24-2010, 02:21 PM
would i need to use another way of getting this trailer?

Yup. I'll have a diddle with it later.

LJackson
03-24-2010, 02:23 PM
appreciate it mate!

Rowsdower!
03-24-2010, 02:44 PM
Source code from the target page:

<div id="trailerspace"></div>
<script type="text/javascript">
showExtras = true;
var videodivid = 'trailerspace';
var theVideoFile = 'http://thehut.pantherssl.com/design-assets/trailers/10066512-20092910.flv';
var theVideoImage = 'http://thehut.pantherssl.com/design-assets/flash/trailer-assets/hutv1.jpg';
var theVideoSkin = 'http://thehut.pantherssl.com/design-assets/flash/trailer-assets/bright.swf';
var theVideoRepeat = 'list';
var theVideoBackColour = '000000';
var theVideoFrontColour = 'FFFFFF';
var theVideoLightColour = '6BC8EA';
var theVideoStretching = 'none';
//var theVideoAutostart = false;
</script>


Your PHP to get file location after the CURL:

$pattern="%theVideoFile = '\K[^']+%";
$match=preg_match($pattern,$input);

The variable $match should then hold the entire path to the video file. Once complete it might be wise to check to make sure that the path is absolute rather than relative incase the other site changes how it links videos but other than that you should be fine.

LJackson
03-24-2010, 03:55 PM
hi Rowsdower,

i have tried this

$uri = 'http://www.thehut.com/dvd/new-moon-double-disc/10066512.html';
$input = file_get_contents($uri);
if (preg_match('%theVideoFile = '\K[^']+%', $input, $match))
{
print $match[0];
}?>

but am getting
Parse error: syntax error, unexpected T_NS_SEPARATOR on line 6

any ideas
thanks

Luke

Rowsdower!
03-24-2010, 07:37 PM
hi Rowsdower,

i have tried this

$uri = 'http://www.thehut.com/dvd/new-moon-double-disc/10066512.html';
$input = file_get_contents($uri);
if (preg_match('%theVideoFile = '\K[^']+%', $input, $match))
{
print $match[0];
}?>

but am getting
Parse error: syntax error, unexpected T_NS_SEPARATOR on line 6

any ideas
thanks

Luke

Since you have single quotes as part of the matched text you will need to use regular quotes rather than single quotes when you wrap the pattern for execution. Based on your code it should look more like this:

$uri = 'http://www.thehut.com/dvd/new-moon-double-disc/10066512.html';
$input = file_get_contents($uri);
if (preg_match("%theVideoFile = 'K[^']+%", $input, $match))
{
print $match[0];
}?>

MattF
03-24-2010, 08:39 PM
$uri = 'http://www.thehut.com/dvd/new-moon-double-disc/10066512.html';
$input = file_get_contents($uri);
if (preg_match("%theVideoFile = 'K[^']+%", $input, $match))
{
print $match[0];
}?>

You're missing the backslash on the K in that snippet.

Rowsdower!
03-24-2010, 08:44 PM
You're missing the backslash on the K in that snippet.

Oops! Nice catch! :thumbsup:

LJackson
03-24-2010, 09:12 PM
nice one mate, works a treat!!!!!!!

thanks
Luke

LJackson
03-24-2010, 09:13 PM
hi,

just a query is there a way to get just the numbers from the url?
the result of


$uri = 'http://www.awin1.com/pclick.php?p=100707130&a=79524&m=2547&platform=cs';
$input = file_get_contents($uri);
if (preg_match("%theVideoFile = '\K[^']+%", $input, $match))
{
print $match[0];
}?>

is

http://thehut.pantherssl.com/design-assets/trailers/10063004-20092311.flv

and i am trying to get just the 10063004-20092311 part? any ideas?

cheers
Luke

LJackson
03-25-2010, 08:39 PM
i've tried a total guess

if (preg_match("%theVideoFile = http://thehut.pantherssl.com/design-assets/trailers/'\K[^']+%", $input, $match))


but it didnt return anything :(


really need to learn preg match :)
cheers
Luke

MattF
03-25-2010, 08:51 PM
Untested:



if (preg_match('#theVideoFile =.+?/trailers/([\d\-]+?)\.flv#', $input, $match))

LJackson
03-25-2010, 08:59 PM
nice one mate,

appreciate it :D
Luke

LJackson
03-25-2010, 10:26 PM
slightly different topic,

any reason why this would not function properly

if($row['merchName'] == "The Hut" || $row['merchName'] == "Send It" && $row['ASIN'] <> "")
{?>

it shows true if the $row['ASIN'] is empty


the following works

if($row['merchName'] == "The Hut" && $row['ASIN'] <> "")
{?>

any ideas?

thanks
Luke

EDIT
===

sorted it :) added () around the first two conditions like so

if(($row['merchName'] == "The Hut" || $row['merchName'] == "Send It") && $row['ASIN'] <> "")

LJackson
03-27-2010, 01:39 AM
ok mate thi should b the last one for a while :)

the url is almost the same as for the code above but there is a slight difference
the previous url was

http://thehut.pantherssl.com/design-assets/trailers/10063004-20092311.flv

and this code worked

if (preg_match('#theVideoFile =.+?/trailers/([\d\-]+?)\.flv#', $input, $match)){


but the new url is like

http://thehut.pantherssl.com/design-assets/trailers/10049799-20091509-c.flv


there is an extra letter which im not sure if it is always a -c as this isnt always present, only for some products

any ideas how to accomadate for it?

many thanks
Luke

MattF
03-27-2010, 02:21 PM
Use w inplace of d.

LJackson
03-28-2010, 06:21 PM
nice one mate, that works fine for the trailers without the -c in them as well which is great :)

do you know of any good(easy to follow) tutorials on this preg_match?

looked at it in the past but found it very confusing to understand, its such a powerful function that i would really like to learn :)

many thanks
Luke

MattF
03-28-2010, 06:26 PM
Quickest reference:

http://docs.google.com/viewer?a=v&q=cache:tpOT17RuGWAJ:www.phpguru.org/downloads/PCRE%2520Cheat%2520Sheet/PHP%2520PCRE%2520Cheat%2520Sheet.pdf+pcre+cheat+sheet&hl=en&gl=uk&pid=bl&srcid=ADGEESjXFa-n63bgF9jNBPwClHBTijkRqmWgci35rRaHKiDXXk0t1a8vbbx-48FESpaawjbKaSwyNotCO8GC2jnpzxjxV6cR41XouAkRsp5cLRzcwW6jumZp29IUtRZGymSnX4jLY4eJ&sig=AHIEtbTMR5tqpr4NdWXTugdYREbK-5U8bA



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum