Jump to content

hayw0027

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hayw0027's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi mate, Yes the script appears to do the right thing but when i used it on my article directory, It adds the new category but it also leaves the old category. So some of the articles are now associated with 2 categories which isn't what I want. I think the query mysql_query("UPDATE wp_term_relationships SET term_taxonomy_id='$my_category' WHERE object_id = '$thisPostHasIt'"); may need some tweaking. Is it possible to make this a find and REPLACE query, would that solve my problem?
  2. Hi, iv found this great little php script posted Andrew Kantor at http://wordpress.org/support/topic/300069?replies=8 that allows you to search your wordpress posts for certain keywords and then inturn places those posts in a category you specify. E.g. Search for posts that have the phrase "Article Marketing" in the title and place them in the "Article Marketing" category. This is perfect for me to use on my article directory that contains 170,000 article posts, posted by people that don't know how to select a targeted category. The only little problem with this script is that it doesn't replace the existing category, it just adds the category you choose to the post and the existing category also remains. Thus having the posts appear in 2 categories each. I know very little about php and mysql queries, iv tried to work it out myself but have wasted about 3 hours doing so. Can someone please take a look at this code and make adjustments so it removes the existing category and replaces it with the category that you desire. Who ever solves this issue will be a God in my eyes for ever. 1. <?php 2. $username="MY_MYSQL_USERNAME"; 3. $password="MY_MYSQL_PASSWORD"; 4. $database="MY_DATABASE_NAME"; 5. $my_text = "/images"; // What I'm searching for 6. $my_category = '8'; // The category to change it to 7. 8. // Connect to MySQL and the database and verify: 9. mysql_connect(localhost,$username,$password) or die(mysql_error()); 10. 11. echo "<p>Connected to MySQL."; 12. mysql_select_db($database) or die(mysql_error()); 13. echo "<br />Connected to " . $database . "</p>"; 14. 15. // Verify what we're looking for, for troubleshooting: 16. echo "<p><b>Looking for " . $my_text . "</b></p>"; 17. 18. // Get the ID field (which is WordPress's post 19. // number) from any posts that have your text: 20. $query = "SELECT ID FROM wp_posts WHERE post_title LIKE '%$my_text%'"; 21. 22. // Take those results and go through them: 23. $result = mysql_query($query) or die(mysql_error()); 24. 25. // While there are results... 26. while($row = mysql_fetch_array($result)) 27. { 28. // Verify what we're doing -- changing post 29. // number such-and-such... 30. $thisPostHasIt = $row['ID']; 31. echo "<p>Row " . $row['ID'] . " contains it, so...<br />"; 32. 33. // In the wp_term_relationships table, 34. // update the category number ("term_taxonomy_id") 35. // with the category number you specified -- but only 36. // in one of the "result" rows. 37. // We look for "object_id" to equal one of those 38. // rows. (The object_id field refers to the WordPress 39. // post number, just as the ID field did. Why two 40. // different names? Who knows?) 41. 42. mysql_query("UPDATE wp_term_relationships SET term_taxonomy_id='$my_category' WHERE object_id = '$thisPostHasIt'"); 43. 44. // And tell us about it: 45. echo "Changing post number " . $thisPostHasIt . " to category number ". $my_category . "</p>"; 46. } 47. echo "<p><b>All done!</b></p>"; 48. ?>
  3. thats not all code because it was 2 big but half of it anyways.
  4. Ok, had a look and i couldnt see it repeated twice, Its a long script but im going to post the lot here. Hope dont get in trouble for it. Its a wordpress plugin and nobody else in the plugin comments have mentioned having this problem and i havent had any responce to mine. Sorry for the hassle people.
  5. Thanks for answering guys. This is lines 60 - 75 $exclude_cat = array($exclude_cats); global $wpdb; $cal_tree = array(); if (!$column_count) $column_count = 1; function get_wpvers() { global $wp_version; preg_match("/\d\.\d/i", $wp_version, $match); // wpmu - increment version by 1.0 to match wp if (strpos($wp_version, 'wordpress-mu') !== false) { $match[0] = $match[0] + 1.0; Ok Neil, il start searching through the script to spot 2 of the same functions
  6. Hey guys, need a little help im getting these errors and cant work out the problem. Fatal error: Cannot redeclare get_wpvers() (previously declared in /hsphere/local/home/..../wp-content/plugins/article-directory/article-directory.php:69) in /hsphere/local/home/...../wp-content/plugins/article-directory/article-directory.php on line 67 This is line 67 and 69: function get_wpvers() { global $wp_version; What is the problem? Thanx
  7. Thanx for replying Im a dumbass when it comes to php code Since the error is appearing on the article pages i presume thats the php code that has the issues. this is it: $this->title = $Article->title.' - '.$this->settings['sitename']; $this->meta_description = substr (strip_tags ($Article->summary), 0, 180); $this->meta_keywords = $Article->keywords; $this->articles = $this->getArticles("article_categoryid = {$Article->Category->id}",'article_id DESC',5); $Article->text = nl2br($Article->text); if ($Article->keywords) { $this->tags = explode(",", $Article->keywords); for ($i=0;$i<sizeof($this->tags);$i++) { $this->words[$i] = trim($this->tags[$i]); $this->tags[$i] = str_replace(" ", "+", $this->words[$i]); } } else { $this->words[] = trim($Category->title); $this->words[] = trim($Article->title); $this->tags[] = str_replace(" ", "+", $this->words[0]); $this->tags[] = str_replace(" ", "+", $this->words[1]); } case "Affiliate Marketing": $category_id='18'; break; case "Article Marketing": $category_id='15'; break; case "Banner Ads": $category_id='20'; break; case "Blogging": $category_id='11'; break; case "Display Marketing": $category_id='10'; break; case "Domain registration": $category_id='22'; break; case "Email Marketing": $category_id='9'; break; case "Forum Marketing": $category_id='17'; break; case "Internet Marketing": $category_id='19'; break; case "Link Building": $category_id='16'; break; case "Pay Per Click": $category_id='5'; break; case "RSS": $category_id='12'; break; case "Search Engine Optimization": $category_id='1'; break; case "Social Networking": $category_id='8'; break; case "Video Marketing": $category_id='7'; break; case "Viral marketing": $category_id='21'; break; case "web 2.o": $category_id='6'; break; case "Web Design": $category_id='14'; break; case "Web Hosting": $category_id='13'; break; $Article->text = str_replace('</a>', '', $Article->text); $Article->text = preg_replace('/(<a[\s]+[^>]+)>/i', '', $Article->text); $this->isarticle = 1; $Article->about = preg_replace('/(<a[\s]+[^>]+)>/i', '\\1 target="_blank">', $Article->about); <?php ini_set('error_reporting', E_ALL | E_STRICT); ini_set('display_errors', 'Off'); ini_set('log_errors', 'On'); ini_set('error_log', '/path/to/errorlog');?>
  8. My directory has a major php script error. The is the error that shows up on top of my article pages. Parse error: parse error, unexpected T_CASE in /hsphere/local/home/user/domain.com/code/articlems.php(45) : eval()'d code on line 25 this is the php code on line 45 of articlems.php eval($this->templatephp); Line 25 says global $Member; where do i look to find the problem? and what would the problem be?
  9. How do i turn off my error log files??? Make it so that error message doesnt appear to the general public???
  10. Hey Guys, Im only just learning the ropes when it comes to php and im having a bit of trouble figuring out some errors that im getting on my site. What does this mean? Parse error: parse error, unexpected T_CASE in /hsphere/local/home/hayw0027/im-articles.com/code/articlems.php(45) : eval()'d code on line 25 This error comes up on the top of every article page in my article directory. e.g http://im-articles.com/other/how-to-spot-a-company-scam.html What do i do to solve this problem? Here is the php code where the problem exists. <?php if (!defined('ARTICLEMS')) { header('HTTP/1.0 403 Forbidden'); die; } /** * Main board view * **/ //---Placeholder Classes--- $Category = new baseclass(); $Comments = new baseclass(); $Article = new baseclass(); $Blocks = new baseclass(); $Page = new baseclass(); $Search = new baseclass(); $Plugin = new baseclass(); //-------------- class articlems extends articlemscore{ function doTemplates($templateset, $templatename){ global $Profile; global $Member; global $Article; global $Category; global $Search; global $Searchresults; global $Blocks; global $Page; global $Plugin; global $Comment; global $time_start; if ($templateset){ if ($templateset == '_MESSAGE'){ $this->output = $templatename; } else{ $this->templatephp = $this->get_template($templateset, $templatename, 1); $this->message = NULL; eval($this->templatephp); if ($this->message != NULL){ $this->output = $this->message; } else{ $this->template = $this->get_template($templateset, $templatename); $this->output = eval($this->formattemplate($templatename, $this->template)); } } } if ($this->bypass_cms == 1){ echo $this->output; exit; } $universal_set = $this->get_templateset('universal'); $universal_set_php = $this->get_templateset('universal',1); eval($universal_set_php['header']); eval($universal_set_php['footer']); eval($universal_set_php['main']); There we go, what do you guys reckon? ???
  11. Does it have to do with the eval($this->templatephp); part of the code or not? Iv got to get this fixed asap any help would be great right now. Thanx
  12. <?php if (!defined('ARTICLEMS')) { header('HTTP/1.0 403 Forbidden'); die; } /** * Main board view * **/ //---Placeholder Classes--- $Category = new baseclass(); $Comments = new baseclass(); $Article = new baseclass(); $Blocks = new baseclass(); $Page = new baseclass(); $Search = new baseclass(); $Plugin = new baseclass(); //-------------- class articlems extends articlemscore{ function doTemplates($templateset, $templatename){ global $Profile; global $Member; global $Article; global $Category; global $Search; global $Searchresults; global $Blocks; global $Page; global $Plugin; global $Comment; global $time_start; if ($templateset){ if ($templateset == '_MESSAGE'){ $this->output = $templatename; } else{ $this->templatephp = $this->get_template($templateset, $templatename, 1); $this->message = NULL; eval($this->templatephp); if ($this->message != NULL){ $this->output = $this->message; } else{ $this->template = $this->get_template($templateset, $templatename); $this->output = eval($this->formattemplate($templatename, $this->template)); } } } if ($this->bypass_cms == 1){ echo $this->output; exit; } $universal_set = $this->get_templateset('universal'); $universal_set_php = $this->get_templateset('universal',1); eval($universal_set_php['header']); eval($universal_set_php['footer']); eval($universal_set_php['main']); There we go, what do you guys reckon?
  13. This is the first part of my php code. <?php if (!defined('ARTICLEMS')) { header('HTTP/1.0 403 Forbidden'); die; } /** * Main board view * **/ //---Placeholder Classes--- $Category = new baseclass(); $Comments = new baseclass(); $Article = new baseclass(); $Blocks = new baseclass(); $Page = new baseclass(); $Search = new baseclass(); $Plugin = new baseclass(); //-------------- class articlems extends articlemscore{ function doTemplates($templateset, $templatename){ global $Profile; global $Member; global $Article; global $Category; global $Search; global $Searchresults; global $Blocks; global $Page; global $Plugin; global $Comment; global $time_start; if ($templateset){ if ($templateset == '_MESSAGE'){ $this->output = $templatename; } else{ $this->templatephp = $this->get_template($templateset, $templatename, 1); I cant see anything wrong with the code on the 25th line. Yes, this is my live site. How do you turn off the error logs. Thankyou Hayz
  14. Hey Guys, Im only just learning the ropes when it comes to php and im having a bit of trouble figuring out some errors that im getting on my site. What does this mean? Parse error: parse error, unexpected T_CASE in /hsphere/local/home/hayw0027/im-articles.com/code/articlems.php(45) : eval()'d code on line 25 This error comes up on the top of every article page in my article directory. e.g http://im-articles.com/other/how-to-spot-a-company-scam.html What do i do to solve this problem? Be great if you can help Thanx Hayz
×
×
  • 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.