Jump to content

Zorg

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Zorg's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=381268:date=Jun 7 2006, 11:46 PM:name=phpuesr1)--][div class=\'quotetop\']QUOTE(phpuesr1 @ Jun 7 2006, 11:46 PM) [snapback]381268[/snapback][/div][div class=\'quotemain\'][!--quotec--] Well you should just change the name of $text to like $Text, That might fix the problem [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] [/quote] Hmm no that doesn't do anything.. I've actually found that script elsewhere on the internet and it is exactly the same as the one I have so I think that should be right. Thanks though
  2. [!--quoteo(post=381265:date=Jun 7 2006, 11:35 PM:name=phpuesr1)--][div class=\'quotetop\']QUOTE(phpuesr1 @ Jun 7 2006, 11:35 PM) [snapback]381265[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] $text = $text." "; $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text." <strong>...</strong> "; [/code] You use $text as a varible in the function twice [/quote] Would that not make it display the result though. I know zilch about php [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] , which line should i change.
  3. Ugh I'm going nuts. I've located some code that repeats itself but I don't think that's causing the problem. There is a tag that says unfinished code so I'm assuming something there is off.
  4. I'm sorry this might be pretty basic to you guys. But i need to fix this code by tomorrow and i have no clue how to do it. It was written by somebody else and I'm not very well versed in PHP. It is supposed to pull an article from a database (image and some text i believe) truncate it into a kind of a blog format and print the result to the screen. When I run it though i get an empty screen. If somebody could help I'd really appreciate it <?php // Function to truncate long text function ShortenText($text) { // Change to the number of characters you want to display $chars = 1000; $text = $text." "; $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text." <strong>...</strong> "; return $text; } // Function to close all HTML tags function close_tags($string) { // match opened tags if(preg_match_all('/<([a-z]+)[ >]/', $string, $start_tags)) { $start_tags = $start_tags[1]; // match closed tags if(preg_match_all('/<\/([a-z]+)>/', $string, $end_tags)) { $complete_tags = array(); $end_tags = $end_tags[1]; foreach($start_tags as $key => $val) { $posb = array_search($val, $end_tags); if(is_integer($posb)) { unset($end_tags[$posb]); } else { $complete_tags[] = $val; } } } else { $complete_tags = $start_tags; } $complete_tags = array_reverse($complete_tags); for($i = 0; $i < count($complete_tags); $i++) { $string .= '</' . $complete_tags[$i] . '>'; } } // Removes the </img> tag $xhtml_tags = array("</img>", "</hr>", "</br>"); $string = str_replace($xhtml_tags, "", $string); return $string; } // Random Featured Author Starts Below define ('HOSTNAME', 'xxxx.xxxxxxx.xxxxxx'); define ('USERNAME', 'xxxxxxxxxxxxxxx'); define ('PASSWORD', 'xxxxxxxxxxxxxxx'); define ('DATABASE_NAME', 'xxxxxxxxxxxxxxxxxxx_xxxxxxx_x'); $db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ('I cannot connect to MySQL.'); mysql_select_db(DATABASE_NAME); # Enter the Archive URL from your Weblog Config and the blog ID number $archive_url="/content/"; $entry_blog_id="1"; // The following finds the number of Authors in the database and puts the value in the variable $num_authors $result = mysql_query("SELECT * FROM mt_entry , mt_author , mt_placement WHERE (entry_blog_id=$entry_blog_id) and (entry_status=2) and (author_id=entry_author_id) and (entry_id=placement_entry_id) and (placement_category_id=2)"); $num_authors = mysql_num_rows($result); //The following finds the number of Authors in the database and puts the value in the variable $num_authors $result = mysql_query("SELECT * FROM mt_entry , mt_author , mt_placement WHERE (entry_blog_id=$entry_blog_id) and (entry_status=2) and (author_id=entry_author_id) and (entry_id=placement_entry_id) and (placement_category_id=2)"); $num_authors = mysql_num_rows($result); $date_seed = date("j"); $bol_found = false; do { if ($num_authors > $date_seed) { $date_seed = $date_seed * 2; } } while ($bol_found = false); //unfinished code $query = "SELECT entry_basename , entry_title, entry_text, entry_text_more, date_format(entry_created_on, '%Y') AS year, date_format(entry_created_on, '%m') AS month, date_format(entry_created_on, '%M %d, %Y') AS readable_date, entry_id, entry_author_id, author_id, placement_category_id, placement_entry_id, author_name FROM mt_entry , mt_author , mt_placement WHERE (entry_blog_id=$entry_blog_id) and (entry_status=2) and (author_id=entry_author_id) and (entry_id=placement_entry_id) and (placement_category_id=2) ORDER by rand() LIMIT 1"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $title = $row['entry_title']; $entry = nl2br($row['entry_text']); // nl2br inserts HTML line breaks $author = $row['author_name']; $permalink_url = $archive_url . "authors_database/" . ($row['entry_basename']) . ".php"; $unsanitized_text = '<h1>' . ($row['entry_title']) . '</h1>' . ShortenText(nl2br($row['entry_text'])); $read_more_about = '<p><a href="' . $permalink_url . '">More about ' . ($row['entry_title']) . '</a> <strong>&raquo;&raquo;</strong></p>'; } mysql_free_result($result); // Print sanitized text $sanitized_text = close_tags($unsanitized_text); echo $sanitized_text, $read_more_about ?>
×
×
  • 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.