Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6130511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:52:01+00:00 2026-05-23T16:52:01+00:00

This code <?php echo Likes: .$r[‘votes_up’].&nbsp;; echo Dislike: .$r[‘votes_down’].; ?> Wont post the values

  • 0

This code

<?php  echo "Likes: ".$r['votes_up']."&nbsp;"; echo "Dislike: ".$r['votes_down'].""; ?>        

Wont post the values from the table for ‘votes_up’ ‘votes_down’
I cant get my head round this! Ive got this exact code working on a different page but it wont on this.
Heres the entire code ….

    <div class="message">
<?php 
$sql = mysql_query("SELECT * FROM threads WHERE id = '" . $_GET['id'] . "'") or die(mysql_error());     
    while($r = mysql_fetch_array($sql))  {
$posted = date("jS M Y h:i",$r['posted']); echo "".$r['author']." &nbsp; $posted";?>
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo "".$r['message'].""; ?>">
        Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<div class="message2"><?php echo "".$r['message'].""; }?></div> 
<?php  echo "Likes: ".$r['votes_up']."&nbsp;"; echo "Dislike: ".$r['votes_down'].""; ?>        
</div>
<br/>
<hr>

Can anyone help? its driving me insane

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:52:02+00:00Added an answer on May 23, 2026 at 4:52 pm

    Your curly bracket is being placed before the last echo statement, therefore the $r variable is out of scope.

    Move the } to later in your page like so

    <div class="message">
    <?php 
        $sql = mysql_query("SELECT * FROM threads WHERE id = '" . mysql_real_escape_string($_GET['id']) . "'") or die(mysql_error());     
        while($r = mysql_fetch_array($sql))
        {
            $posted = date("jS M Y h:i",$r['posted']);
            echo $r['author']." ".$posted;
    ?>
    <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo $r['message']; ?>">
        Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
    <div class="message2">
        <?php
            echo $r['message']; 
        ?>
    </div> 
        <?php
            echo "Likes: ".$r['votes_up']."&nbsp;";
            echo "Dislike: ".$r['votes_down'];
        } 
        ?>        
    </div>
    <br/>
    <hr>
    

    Also notice the call to mysql_real_Escape_string in the $sql var. this will prevent nasty sql injections

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a PHP code like this $site=http://www.google.com; $content = file_get_content($site); echo $content; But
I have this PHP code echo '<a href=# onclick=updateByQuery(\'Layer3\', ' . json_encode($query) . ');>Link
Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?>
In this code : $path = C:\NucServ\www\vv\static\arrays\news.php; $fp = fopen($path, w); if(fwrite($fp=fopen($path,w),$text)) { echo
when I run this code for the first time <?php session_start(); echo SID; ?>
Stupid question, this code: <?php $variable = system(cat /home/maxor/test.txt); echo $variable; ?> with file
i have the following code : <input type=text value=<?php echo $_GET['msg']; ?>> This input
this is my entire PHP code: <?php if(empty($_POST['selid'])) {echo no value selected; } else
This is some example PHP code code; <?php function myFunc() { echo blue; }
I have this code: document.getElementById('root').style.left = '<?php echo $page_position[$info[os]][$info[browser]][0]; ?>'; document.getElementById('root').style.top = '<?php echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.