Jump to content

Dyslexic and just cant get this right... HELP PLEASE


Mouse

Recommended Posts

Ok so i have been playing with my site for a while and getting there very slowly... but heres the rub i am DYSLEXIC and am having issues following a tutorial and the code therein... the tutorial / code is over at http://www.scriptplayground.com/tutorials/php/Tag-Cloud/ and  where i am at is

[code]
<html>
<head>
<style type="text/css">
.tag_cloud { padding: 3px; text-decoration: none; }
.tag_cloud:link  { color: #81d601; }
.tag_cloud:visited { color: #019c05; }
.tag_cloud:hover { color: #ffffff; background: #69da03; }
.tag_cloud:active { color: #ffffff; background: #ACFC65; }
</style>
</head>

<body>
<?php
function get_tag_data() {
$host = "localhost";
$dbname = "###";
$dbuser = "###";
$dbpass = "###";

$connection = mysql_connect($host, $dbuser, $dbpass) or die(mysql_error());
$db = mysql_select_db($dbname) or die(mysql_error());

  $result = mysql_query("SELECT uid ,firstname ,lastname FROM user ORDER BY uid DESC limit 20");
  while($row = mysql_fetch_array($result)) {
    $arr[$row['firstname, lastname']] = $row['count'];
  }
  ksort($arr);
  return $arr;
}

function get_tag_cloud() {

$min_font_size = 100%;
$max_font_size = 250$;

$tags = get_tag_data();
$minimum_count = min(array_values($tags));
$maximum_count = max(array_values($tags));
$spread = $maximum_count - $minimum_count;

if($spread == 0) {
    $spread = 1;
}

$cloud_html = '';
$cloud_tags = array(); // create an array to hold tag code
foreach ($tags as $tag => $count) {
$size = $min_font_size + ($count - $minimum_count)
* ($max_font_size - $min_font_size) / $spread;
$cloud_tags[] = '<a style="font-size: '. floor($size) . 'px'
. '" class="tag_cloud" href="http://www.mouse.nodstrum.com/full_profile?u$uid . '" title="\'' . $firstname $lastname . '\' profile">'
. htmlspecialchars(stripslashes($tag)) . '</a>';
}
$cloud_html = join("\n", $cloud_tags) . "\n";
return $cloud_html;

?>

//Here is some example HTML to call this tag builder.
<h3>Sample Tag Cloud results</h3>
<div id="wrapper"
<!-- BEGIN Tag Cloud -->
<?php print get_tag_cloud(); ?>
<!-- END Tag Cloud -->
</div>

</body>
</html>
[/code]

okay, so it is only likely to be a missing ; or me mixing $uid and $did <b>BUT</b> if anyone can help i would be most appreciative

many thanks

Mouse
Link to comment
Share on other sites

sorry should have said... error message says

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/nodstrum/public_html/mouse/xxxtag.php on line 51

thats the one that starts . '" class="tag_cloud" href="http://
Link to comment
Share on other sites

You forgot a period between $firstname and $lastname.
[code=php:0]
$cloud_tags[] = '<a style="font-size: '. floor($size) . 'px'
. '" class="tag_cloud" href="http://www.mouse.nodstrum.com/full_profile?u$uid . '" title="'' . $firstname . $lastname . '\' profile">'
. htmlspecialchars(stripslashes($tag)) . '</a>';[/code]



EDIT: And you have your quotes mixed up around uid. I'm guessing it's suppose to be like this..
[code=php:0]$cloud_tags[] = '<a style="font-size: '. floor($size) . 'px'
. '" class="tag_cloud" href="http://www.mouse.nodstrum.com/full_profile?u=' . $uid . '" title="'' . $firstname . $lastname . '\' profile">'
. htmlspecialchars(stripslashes($tag)) . '</a>';[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.