Jump to content

cataiin

Members
  • Posts

    49
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    localhost
  • Age
    19

cataiin's Achievements

Newbie

Newbie (1/5)

2

Reputation

  1. It's just an example. I want to know how to send multiple queries - in my case. Thanks.
  2. This creates the table and inserts only one row. After refresh, no change. But if I replace $query .= with $query = and then refresh page (after first row was inserted), I get all rows, but first one duplicated. How I can fix this - to create all rows from first time when the code is executed? $url = file_get_contents('http://lorem.ipsum'); preg_match_all('|href/(tt\d+)|i', $url, $id); preg_match_all('|<div id=aba>([^<]*)</div>|i', $url, $date_and_text); $count = count($date_and_text[1]) - 1; for ($i=0; $i <= $count; $i++) { $date = substr($date_and_text[1][$i], 0, ; $text = substr($date_and_text[1][$i], 22); $tomorrow = date('d.m.Y', strtotime('+1 day')); $query = "CREATE TABLE `".$tomorrow."` (id varchar(255), date varchar(255), text varchar(255));"; $query .= "INSERT INTO `".$tomorrow."` VALUES ('{$id[1][$i]}', '{$date}', '{$text}')"; $send_to_mysql = mysqli_multi_query($connection, $query); }
  3. Aww, thanks. strstr return what I want, but only one result and I need all of them. I need to find all data between http://www.imdb.com/title/ and "> and save them to MySQL.
  4. I have this code: $url = file_get_contents('http://lala.com'); $before_imdb_url = 'http://www.imdb.com/title/'; $after_imdb_url = '">'; $imdb_url = strstr(substr($url, strpos($url, $before_imdb_url) + strlen($before_imdb_url)), $after_imdb_url, true); var_dump($imdb_url); ...result: string(15) "tt119247" ...and two questions: 1. is in my case best (and fastest) way to use strstr or should I use something else - and what? 2. my code returns only one result, but there's more. I've tried with foreach but no succes: foreach ($imdb_url as $a) { echo $a; } what should I do?
  5. Nobody? If you don't understand please ask, my english is kinda bad.
  6. Hello. I have a (big) text and a JSON file containing url needed. But execution time is toooo long. $texts returns string(50) "Lorem ipsum dolor sit amet, consectetur adipiscing" string(50) "elit. Cras diam velit, lobortis nec fermentum id, " string(46) "congue nec nibh. Pellentesque pretium, dui ut." $text_encode = rawurlencode($texts); $url_address = @file_get_contents('http://api.url/?text='.$text_encode); http://api.url/?text=something it's a JSON result. So I use this to select and get .mp3 file: $before_address = '"url":"'; $after_address = '","format"'; $address = strstr(substr($url_address, strpos($url_address, $before_address) + strlen($before_address)), $after_address, true); $mp3 = @file_get_contents($address); and to save... $part = 1; $files = 'audio/parts/'.md5($mp3).'-'.$part.'.mp3'; $file_final = '/audio/'.md5($mp3)'.mp3'; $save_mp3 = file_put_contents($files, $mp3); $save_mp3_final = file_put_contents($file_final, $mp3, FILE_APPEND); It's file_get_contents a bad practice in both cases? Or file_put_contents used two times? What should I use to retrieve data faster...? Thanks. I've been thinking about json_decode and cURL, but never used and I don't know if it's best method to solve my problem.
  7. <form method="post"> <textarea name="textarea"></textarea> <input type="submit" /> </form> <?php $file = "text.txt"; $text = $_POST["textarea"]; $text_ok = nl2br($text); file_put_contents($file, $text_ok); include "text.txt"; ?>
  8. Ah, sorry. Then I saw you already use nl2br. Try to replace: <p><?php echo stripslashes(nl2br($reply->content)); ?></p> with: <p><?php echo nl2br(stripslashes($reply->content)); ?></p>
  9. http://php.net/manual/en/function.nl2br.php
  10. with preg_match: if(preg_match("/$word/", $target)) { echo "Exists."; } else { echo "Nop."; } sorry but then I saw you want with preg_match.
  11. if(strpos($target, $word) !== false) { echo "Exists."; } else { echo "Nop."; }
  12. what returns: echo "<a href='".$modelurl.$item['performerid'].$modelpagenext."'><img src='".$file."' width='160px' height='120px' border='0px' alt='' /></a>"; ?
  13. try: echo "<img src='".$file."' width='160px' height='120px' border='0px' alt='' />"; echo "<a href='".$modelurl.$item['performerid']."'>".$modelpagenext."</a>";
×
×
  • 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.