Jump to content

[SOLVED] Inerting content of file in database


Recommended Posts

Hello i have problem with inserting content of file. My code is:

 

<?php

$l="www.something.net";

$cg = file_get_contents($l);

$cg = strip_tags($cg);

$cg = mysql_real_escape_string($cg);

$cg = str_replace ('\n',' ', $cg;

$cg = str_replace ('\t',' ', $cg);

$cg = str_replace ('\0',' ', $cg);

$cg = str_replace ('\xOB',' ', $cg);

mysql_query("INSERT INTO table (content) VALUES ('$cg');") ;

?>

 

This is work but problem is that i get lot of squars i think that they represent some blank space  in pages but i can not remove them.

for exammple i get in mysql: square squre  some text square sguare square squre some text.

 

I have more squres then text i need to remove theme

Can someone help me?

 

Thank you

Thank you for replay this is solve my problem but now other thing do not work.

I want to strip all between <script></script> tags but my code do not work well.

This code goes before strip_tags

 

preg_match_all('/<script(.*)<\/script>/i', $cg, $script);

foreach ($script[1] as $s)

{ $cg = str_replace ($s,' ', $cg);

}

 

This is sript all content of website and i get empty sting in the database.

I want to strip only text between these tags.

Page have lot of script tags.

 

 

 

 

This is work when you have one script tags.

But if u have more then do not. For example

 

<?php

$string = "test <script>tasetsetasetst</script> test2<script>tasetsetasetst</script>";

$string = preg_replace('/<script(.*)<\/script>/i', '', $string);

 

echo $string;

die();

?>

 

result of this will be test, i want to get test test2

Thank you

<?php
$string = "test <script>tasetsetasetst</script> test2<script>tasetsetasetst</script>";
$string = preg_replace('%<script(.+?)<\/script>%is', '', $string);

echo $string;
die();
?>

 

Try that.

 

Word between tabs topic for more in-depth information on regex.

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.