Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. is it what you try <?php $body = 'I am (15,23,96) y old and I go to (Paris,Wien,Los Angeles,Rim).'; $body = explode('(', $body); $out = $body[0]; for ($i = 1; $i < count($body); $i++){ $con = explode(')',$body[$i]); $pos = explode(',', $con[0]); $out .= $pos[rand(0, count($pos)-1)]. $con[1]; } echo $out; ?>
  2. try <?php mysql_connect('localhost'); mysql_select_db('test'); $res = mysql_query('select customer_id FROM customer ORDER BY customer_id' ); $j = mysql_num_rows($res); $i = 0; while ($i < $j and mysql_result($res, $i, 0) == $i) $i++; echo 'Next available number is: ', $i; ?>
  3. try <?php mysql_connect('localhost'); mysql_select_db('test'); $res = mysql_query('select customer_id FROM customer ORDER BY customer_id' ); $j = mysql_num_rows($res); $i = 0; while ($i++ < $j and mysql_result($res, $i - 1, 0) == $i); echo 'Next available number is: ', $i; ?>
  4. use mysql_data_seek() function to reset $Projects to first row (index = 0)
  5. where is form from which $_POST['addon'] come
  6. maybe call preg_replace more then one time <?php $mytext = '[quote]here is some text[quote]here is some text[/quote][/quote]'; while (preg_match('/\[quote\](.+?)\[\/quote\]/is', $mytext)) $mytext = preg_replace('/\[quote\](.+?)\[\/quote\]/is', '<pre>$1</pre>', $mytext); echo $mytext; ?>
  7. SQL must be "DELETE FROM table WHERE id=$id_to_delete_1 OR id=$id_delete_2 OR id=$id_delete_3"
  8. try <?php $old_arraj = array ( 0 => array ( 1182529800 => array ( 'time' => 1182529800, 'type' => 'Middle', 'date' => '12:30', 'bgcolor' => 1, ), 1182531600 => array ( 'time' => 1182531600, 'type' => 'Middle', 'date' => '13:00', 'bgcolor' => 1, ), ), 1 => array ( 1182519000 => array ( 'time' => 1182519000, 'type' => 'Middle', 'date' => '9:30', 'bgcolor' => 0, ), 1182520800 => array ( 'time' => 1182520800, 'type' => 'Middle', 'date' => '10:00', 'bgcolor' => 0, ), 1182522600 => array ( 'time' => 1182522600, 'type' => 'Middle', 'date' => '10:30', 'bgcolor' => 0, ), ), 2 => array ( 'time' => '1182517200', 'type' => 'Start', 'date' => '9:00', 'bgcolor' => 0, ), 3 => array ( 'time' => '1182524400', 'type' => 'End', 'date' => '11:00', 'bgcolor' => 0, ), 4 => array ( 'time' => '1182528000', 'type' => 'Start', 'date' => '12:00', 'bgcolor' => 1, ), 5 => array ( 'time' => '1182533400', 'type' => 'End', 'date' => '13:30', 'bgcolor' => 1, ), ); $new_array =array(); foreach ($old_arraj as $old) if (array_key_exists('time',$old)) $new_array[] = $old; else $new_array = array_merge($new_array,$old); array_multisort($new_array); foreach ($new_array as $value) echo $value['date'], ' - ', $value['type'], "<br />\n"; ?>
  9. try <?php $match1 = array($Topic, $Subtopic, $Theswords); foreach ($match1 as $k => $v) if($v == '') unset($match1[$k]); echo $match1 = implode(', ', $match1); ?> btw all $match is same, isn't it
  10. try $text=preg_replace('/\[url\]([^[]*)\[\/URL\]/', '<a href="$1" target="_blank">$1</a>', $text);
  11. change $name = $_POST['ArtistName']; $sql = "INSERT INTO TblArtist SET ArtistName='$ArtistName'"; to $name = $_POST['ArtistName']; $sql = "INSERT INTO TblArtist SET ArtistName='$name'";
  12. change lines 132, 165 and 170 to ... $emailedyet="false"; ... mail("abuse@freemoviesonline.eu", "Subject: PHP Form Processor: Email Injection", "The IP ".$_SERVER["REMOTE_ADDR"]." tried to inject email headers into the form processor please add this IP to the blacklist makeing this IP enable to submit contact forms.", "From: null@null.com" ); ... IP: ".$_SERVER["REMOTE_ADDR"]."<br />
  13. change line $total_results = mysql_num_rows($r); to $total_results = mysql_result($r,0,0);
  14. change $result=mysql_query($query); to $result=mysql_query($query) or die(mysql_error());
  15. change echo '<a href="http://mysite.com/page.php?id=$id">copy this link and send it to your friends</a>'; to echo '<a href="http://mysite.com/page.php?id='.$id.'">copy this link and send it to your friends</a>';
  16. you pull data from database you use SQL to pull out dat SQL look something like 'SELECT something FROM table_name WHERE something etc. i suggest that you add and type='Y' in your SQL in this case you pull just data that have in field type value 'Y' I think that you don't need to echoed empty rows
  17. try <?php $tree= array( 0=>array('id'=>1, 'parent'=>0), 1=>array('id'=>2, 'parent'=>0), 2=>array('id'=>3, 'parent'=>2), 3=>array('id'=>4, 'parent'=>3), 4=>array('id'=>5, 'parent'=>2), 5=>array('id'=>6, 'parent'=>0), 6=>array('id'=>7, 'parent'=>3), 7=>array('id'=>8, 'parent'=>4), 8=>array('id'=>9, 'parent'=>1), 9=>array('id'=>10, 'parent'=>0), 10=>array('id'=>11, 'parent'=>10), ); function my_tree($tree, $start = 0, $r = 0, $first_loop = true) { if ($first_loop) { //reorganize the array $tmp=array(); foreach ($tree as $a) $tmp[$a['parent']][] = $a['id']; $tree = $tmp; } else $out = "\n".'-'.str_repeat('-',$r++).$start.'<br />'; if (isset($tree[$start])){ if (is_array($tree[$start])) { foreach ($tree[$start] as $v){ $out .= my_tree($tree, $v, $r, false); } } } return $out; } echo my_tree($tree); ?>
  18. in your sql use WHERE ... AND type ='Y' etc. ... mens what you have now in where part etc means rest of your sql
  19. ok i see mistakes 1st change line $lm = ' LIMIT '.(($page - 1) * $limit).' '.$limit; to $lm = ' LIMIT '.(($page - 1) * $limit).', '.$limit; add comma 2nd change line echo $qve_data = "SELECT count(*) FROM teachersname".$where.$lm; to echo $qve_data = "SELECT * FROM teachersname".$where.$lm; remove count
  20. try <?php //conect to db $limit = 2; $fields = array("laptopname", "statusID"); if (isset($_GET['search']) and $_GET['search'] == 'Search'){ $page = trim(addslashes(strip_tags($_GET['page']))); if($page == "" OR !is_numeric($page)) $page = 1; $find = strtoupper($_GET['finda']); $find = strip_tags($_GET['finda']); $find = trim ($_GET['finda']); $find = mysql_real_escape_string($find); if (in_array($_GET['field'], $fields)) $field = $_GET['field']; else die('wrong field name'); if ($find) $where = ' WHERE '.$field." LIKE '%".$find."%'"; else $where = ' WHERE 1'; $lm = ' LIMIT '.(($page - 1) * $limit).' '.$limit; $qve_tot_row = "SELECT count(*) FROM teachersname".$where; echo $qve_data = "SELECT count(*) FROM teachersname".$where.$lm; echo '<br />; $res = mysql_query($qve_tot_row); $tot_row = mysql_result($res, 0, 0); $tot_pages = ceil($tot_row / $limit); $res =mysql_query($qve_data) or die(mysql_error()); if (mysql_num_rows($res) > 0) { while($result = mysql_fetch_array($res)) { echo"<table width=\"200\" border=\"0\" class=\"border_bottom\"> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Client Name</strong>"; echo "</td>"; echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_client_details.php?recordID=<?php echo $result['Client']; ?>"><?php echo $result['Client']; ?> </a></em> <?php echo " </td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Department Code</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['DepartmentCode']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "</table> \n"; echo"<br>"; } } else echo 'no result'; if ($page > 1) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; else echo ' PREV '; for ($i =1; $i <= $tot_pages; $i++) { if ($i != $page) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; else echo " $i "; } if ($page < $tot_pages) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; else echo ' NEXT '; } else die('error'); ?> what is output
  21. try <?php $myArray = Array( Array('apple','20','source1'), Array('banana','22','source1'), Array('pear','28','source2'), Array('apple','33','source2'), Array('banana','15','source2')); $tmp = array(); $out = array(); foreach ($myArray as $v) if (!array_key_exists($v[0],$tmp) or $v[1] < $tmp[$v[0]][1]) $tmp[$v[0]] = $v; foreach ($tmp as $v) $out[] = $v; print_r($out); ?>
×
×
  • 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.