Jump to content

dreamwest

Members
  • Posts

    1,223
  • Joined

  • Last visited

    Never

Everything posted by dreamwest

  1. your simply calling a function that doesnt exist - num_rows() on a non-object
  2. Simplest join possible $result = mysql_query("SELECT * FROM term_taxonomy AS a, terms as b WHERE a.term_id=b.term_id");
  3. Write to database instead of file. Ive tried experiments on speed with ifelse and functions - ifelse wins so you cant do much there. If your using this to display content use flush(); to output the outlay as fast as possible
  4. You could have spaces in you keyword column _ppi Try: SELECT * FROM `keywords` WHERE `keyword` LIKE 'ppi'
  5. Another way to do it to query the database and write the whole thing to a file /*************** config ***************/ $mysql_host=''; $mysql_database='' database name $mysql_username=''; // user name $mysql_password=''; // password $storing_dir = ""; // directory path with an ending slash /******************* end config ************/ $file_name = $mysql_database."_".date('YmdHis').".sql"; $link = mysql_connect($mysql_host, $mysql_username, $mysql_password); if (!$link) { fwrite($fh, 'Could not connect: ' . mysql_error()); exit(); } $db_selected = mysql_select_db($mysql_database, $link); if (!$db_selected) { fwrite($fh, 'Can\'t use $mysql_database : ' . mysql_error()); exit(); } $myFile = $storing_dir . $file_name; $fh = fopen($myFile, 'w') or die("can't open file"); _mysqldump($mysql_database); fclose($fh); function _mysqldump($mysql_database) { global $fh; _mysqldump_schema_structure($mysql_database); $sql="show tables;"; $result= mysql_query($sql); if( $result) { while( $row= mysql_fetch_row($result)) { _mysqldump_table_structure($row[0]); _mysqldump_table_data($row[0]); } } else { $content = "/* no tables in $mysql_database */\n"; fwrite($fh, $content); } mysql_free_result($result); } function _mysqldump_schema_structure($schema) { global $fh; fwrite($fh, "/* database : `$schema` */\n"); $sql="show create schema `$schema`; "; $result=mysql_query($sql); if( $result) { if($row= mysql_fetch_assoc($result)) { fwrite($fh, $row['Create Database'].";\n\n"); } } fwrite($fh, "USE `$schema`; \n\n"); mysql_free_result($result); } function _mysqldump_table_structure($table) { global $fh; fwrite($fh, "/* Table structure for table `$table` */\n"); fwrite($fh, "DROP TABLE IF EXISTS `$table`;\n\n"); $sql="show create table `$table`; "; $result=mysql_query($sql); if( $result) { if($row= mysql_fetch_assoc($result)) { fwrite($fh, $row['Create Table'].";\n\n"); } } mysql_free_result($result); } function _mysqldump_table_data($table) { global $fh; $sql="select * from `$table`;"; $result=mysql_query($sql); if( $result) { $num_rows= mysql_num_rows($result); $num_fields= mysql_num_fields($result); if( $num_rows > 0) { fwrite($fh, "/* dumping data for table `$table` */\n"); $field_type=array(); $i=0; while( $i < $num_fields) { $meta= mysql_fetch_field($result, $i); array_push($field_type, $meta->type); $i++; } //print_r( $field_type); fwrite($fh, "insert into `$table` values\n"); $index=0; while( $row= mysql_fetch_row($result)) { fwrite($fh, "("); for( $i=0; $i < $num_fields; $i++) { if( is_null( $row[$i])) fwrite($fh, "null"); else { switch( $field_type[$i]) { case 'int': fwrite($fh, $row[$i]); break; case 'string': case 'blob' : default: fwrite($fh, "'".mysql_real_escape_string($row[$i])."'"); } } if( $i < $num_fields-1) fwrite($fh, ","); } fwrite($fh, ")"); if( $index < $num_rows-1) fwrite($fh, ","); else fwrite($fh, ";"); fwrite($fh, "\n"); $index++; } } } mysql_free_result($result); fwrite($fh, "\n"); }
  6. You need to $_GET the page and use startfrom in your query http://site.com/index.php?q=searching&page=3 This is an example //get the total for the search here $total = //query here $tpage = ceil( $total / 30 ); $startfrom = ( $page - 1 ) * 30; $sql = "SELECT * FROM table where something ='query' LIMIT {$startfrom}, 30"; $result = mysql_query( $sql ); //now page stuff $content_count = mysql_num_rows( $result ); $start_num = $startfrom + 1; $end_num = $startfrom + $content_count; $prev = $page - 1; $next = $page + 1; $adjust = 9; if ( 1 < $page ) { $page_links .= "<a class=pagination_prev href='".$prev."'><< Prev</a><a class=pagination_next href='1'>1</a>...."; } $k = $page - $adjust; for ( $page ; $k <= $page + $adjust; ++$k ) { if (( 0 < $k ) && ( $k <= $tpage ) ) { if(($page)==($k)){ $page_links.="<span class=\"pagination_active\"> ".$k." </span>"; } else { $page_links .= "<a class=pagination href='".$k."'>{$k}</a>"; } } } if ( $page < $tpage ) { $page_links .= ".....<a class=pagination_next href='".$tpage."'>".$tpage."</a><a class=pagination_next href='".$next."'>Next >></a>"; }
  7. Really!? What about this... RewriteRule ^([^/\.]+)/(.*)/(.*) index.php?section=$2&action=$3&root=$1 [L,QSA] I win
  8. Your over complicating it. You just need the total and page reference And dont forget ceil Example: $page = 1; $tpage = ceil( $total_pics / 30 ); $startfrom = ( $page - 1 ) * 30; $start_num = $startfrom + 1; $end_num = $startfrom + $total_pics; $prev = $page - 1; $next = $page + 1; $adjust = 9; if ( 1 < $page ) { $page_links_pics .= "<a class=pagination_prev href='/hdpics/".$prev."'><< Prev</a><a class=pagination_next href='/hdpics/1'>1</a>...."; } $k = $page - $adjust; for ( $page ; $k <= $page + $adjust; ++$k ) { if (( 0 < $k ) && ( $k <= $tpage ) ) { if(($page)==($k)){ $page_links_pics.="<span class=\"pagination_active\"> ".$k." </span>"; } else { $page_links_pics .= "<a class=pagination href='/hdpics/".$k."'>{$k}</a>"; } } } if ( $page < $tpage ) { $page_links_pics .= ".....<a class=pagination_next href='/hdpics/".$tpage."'>".$tpage."</a><a class=pagination_next href='/hdpics/".$next."'>Next >></a>"; }
  9. RewriteRule ^index/login/members index.php?section=members&action=login [L,QSA]
  10. $stuff = '<!-- open tag --> <a href="http://www.phpfreaks.com>PHP Freaks</a> <!-- / open tag -->'; $no_stuff = explode( "<a href="http://www.phpfreaks.com>PHP Freaks</a>", $stuff); echo $no_stuff[0] . $no_stuff[2];
  11. function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); }
  12. in this case yes ... in all cases ... maybe not. that is why people are trying to give him a solution that works in ALL cases just explode the href=" part to get the url Now say after me $message = 'Regex is the best ! All hail explode'; $value=explode("!", $message); $value = trim($value[1]); echo $value;
  13. Apparently its the same thing: href="http://www.mysite.com/?d=9FDS32S" target="_blank">http://www.mysite.com/?d=9FDS32S</a>
  14. <a href="something.php">DOWNLOAD</a> will become DOWNLOAD See my second post
  15. Thanks! Ive been trying to get that one for a while now
  16. Of course it does....and this assumes this is a link $message = '<a rel="nofollow" href="http://www.mysite.com/?d=9FDS32S" target="_blank">http://www.mysite.com/?d=9FDS32S</a>'; $value=explode("</a>", $message); $value=explode(">", $value[0]); $value = trim($value[1]); echo $value;
  17. $message = '<a rel="nofollow" href="http://www.mysite.com/?d=9FDS32S" target="_blank">http://www.mysite.com/?d=9FDS32S</a>'; $value=explode('target="_blank">', $message); $value=explode("</a>", $value[1]); $value = trim($value[0]); echo $value;
  18. Im transfering files using curl but get a timeout error: Fatal error: Allowed memory size of 85983232 bytes exhausted (tried to allocate 50681183 bytes) in /home/user/public_html/vids.php on line 71 I have a timeout just before the curl but it doesnt seem to fix it: set_time_limit(0);
  19. Make css and images ...everything thats included, a full url http://site.com/style.css
  20. I have a really long document, but only need a single word/s within two specific tags words here..... <link>only get this line</link> lots of words here..... How can i just get what is within the <link> tags??
  21. im assuming this url is not real, but it has to exist http://www.health-issues.net/$1/ja. It has to be something like http://www.health-issues.net/ja/index.php?language=$1 What is the real address??
  22. # permanently redirect from www domain to non-www domain RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC] RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L] OR # redirect from old domain to new domain RewriteEngine On RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L] OR # redirect an entire site via permanent redirect Redirect permanent / http://www.domain.com/
  23. I deliberately left this out so you can test the dynamic rule Now you just need the default ive changed it so it wont conflict with any other rule. #default for all sections -> http://site.com/type=news or http://site.com/type=forum RewriteRule ^type=(.*) index.php?type=$1 [L,QSA]
×
×
  • 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.