/    Sign up×
Community /Pin to ProfileBookmark

Code works locally, but not online.

Hi peopole.

I have some php code that won’t execute properly online, however it works perfectly on my local test server.

Can anyone help me?

this is the code…

[code]
$text = ‘<div><object width=”425″ height=”335″><param name=”movie” value=”http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7″></param><param name=”allowfullscreen” value=”true”></param><embed src=”http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7″ type=”application/x-shockwave-flash” width=”425″ height=”335″ allowfullscreen=”true”></embed></object><br /><b><a href=”http://www.dailymotion.com/video/x2ln7h_gagner-de-l-argent-en-restant-chez_videogames”>GAGNER DE L ARGENT EN RESTANT CHEZ SOI</a></b><br /><i>Uploaded by <a href=”http://www.dailymotion.com/zdax6″>zdax6</a></i></div>’;

echo preg_replace(“/.*?value=”(.*?)”.*/si”, “$1”, $text);
[/code]

It basically takes the line “http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7” out of that code with regular expressions.

It works locally on my test server, but when i put it online it doesn’t seem to be having any effect on it.

PLEASE SOMEONE HELP! IT WOULD BE MUCH APPRECIATED!!

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@ripeJul 25.2007 — Hi rapidz,

I really don't understand what $1 is in your code. Variables can not start with number as I know.

If you are trying to replace the link try to use :
[code=php]<?php

$replace = 'http://www.dailymotion.com/swf/NEWNEWNEW';
$text = '<div><object width="425" height="335"><param name="movie" value="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7"></param><param name="allowfullscreen" value="true"></param><embed src="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7" type="application/x-shockwave-flash" width="425" height="335" allowfullscreen="true"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x2ln7h_gagner-de-l-argent-en-restant-chez_videogames">GAGNER DE L ARGENT EN RESTANT CHEZ SOI</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/zdax6">zdax6</a></i></div>';

echo preg_replace("/.*?value="(.*?)".*/si", "$replace", $text);

?>[/code]



Hope it helps,

Mihai
Copy linkTweet thisAlerts:
@rapidzauthorJul 25.2007 — what i'm trying to do is take the "http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7" out of all that text and store it in a variable.

It works fine locally, but not on the web...
Copy linkTweet thisAlerts:
@ripeJul 25.2007 — I'm not sure where do you get that $text content from ?

I use a function to get the contents for text or cURL operations.

This code should work online, upload it if it's not working and post the link for exact code:

[code=php]
<?php
function get_middle($source, $beginning, $ending, $init_pos) {
$beginning_pos = strpos($source, $beginning, $init_pos);
$middle_pos = $beginning_pos + strlen($beginning);
$ending_pos = strpos($source, $ending, $beginning_pos + 1);
$middle = substr($source, $middle_pos, $ending_pos - $middle_pos);
return $middle;
}

$text = '<div><object width="425" height="335"><param name="movie" value="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7"></param><param name="allowfullscreen" value="true"></param><embed src="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7" type="application/x-shockwave-flash" width="425" height="335" allowfullscreen="true"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x2ln7h_gagner-de-l-argent-en-restant-chez_videogames">GAGNER DE L ARGENT EN RESTANT CHEZ SOI</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/zdax6">zdax6</a></i></div>';

// assign to $get
$get = get_middle($text, 'value="http:', '"></param', 0);

echo $get;

?>
[/code]


Or what errors you get ?

Give more details pls so I may help
Copy linkTweet thisAlerts:
@rapidzauthorJul 25.2007 — surely thats a lot of code for what i want to do, isn't there an easier way??

here's my original topic if this helps...

http://www.webdeveloper.com/forum/showthread.php?p=782452#post782452
Copy linkTweet thisAlerts:
@ripeJul 25.2007 — I'm not sure, I always use that function to get content. You have it assigned to $get .. just copy paste you don't need to modify anything.

Thanks
Copy linkTweet thisAlerts:
@rapidzauthorJul 25.2007 — it outputs this...

width="425" height="335">
Copy linkTweet thisAlerts:
@ripeJul 25.2007 — it outputs this...

width="425" height="335">[/QUOTE]



Do you have the exact $test content ? where you test ?

If not :

$get = get_middle($text, '[B]value="http:[/B]', '[B]"></param[/B]', 0);

Replace the bold text with exact tags between which the content will output.

if you want to get : cat from next string "<sdhjcgbsd?jcat;tya"

USE:

$get = get_middle($text, 'd?j', ';ty', 0);

I hope you got how function works, it worked for me all the times, it should work fine for you as well.

Hope it helps
Copy linkTweet thisAlerts:
@rapidzauthorJul 25.2007 — still doesn't work, even when i do that.

The original code i posted works locally, but not online - i just cannot understand why. its insane.
Copy linkTweet thisAlerts:
@ripeJul 25.2007 — Can you create a file.php with my 1st code , upload it and give me the link. It should work 100% online.

If you have a different code, I can help only if I see the entire code.
Copy linkTweet thisAlerts:
@MrCoderJul 25.2007 — [code=php]
$text = '<div><object width="425" height="335"><param name="movie" value="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7"></param><param name="allowfullscreen" value="true"></param><embed src="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7" type="application/x-shockwave-flash" width="425" height="335" allowfullscreen="true"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x2ln7h_gagner-de-l-argent-en-restant-chez_videogames">GAGNER DE L ARGENT EN RESTANT CHEZ SOI</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/zdax6">zdax6</a></i></div>';

echo preg_replace("/.*?value="(.*?)".*/si", "1", $text);
[/code]


Ripe, $1 is an internal value used in preg, it means use the first match as the replacement string.

Threw me off by making a new post, glad I spotted it ?

Try changing the $1 for a 1 instead, I know some web servers conform to different preg values.

If that is still no help then can you upload the following to your server and give us a link?

[code=php]
<?php
$text = '<div><object width="425" height="335"><param name="movie" value="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7"></param><param name="allowfullscreen" value="true"></param><embed src="http://www.dailymotion.com/swf/6TMx6A6bDKSlyikB7" type="application/x-shockwave-flash" width="425" height="335" allowfullscreen="true"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x2ln7h_gagner-de-l-argent-en-restant-chez_videogames">GAGNER DE L ARGENT EN RESTANT CHEZ SOI</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/zdax6">zdax6</a></i></div>';

var_dump($text);
?>
[/code]
×

Success!

Help @rapidz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.11,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...