Jump to content

Warning: mysql_fetch_array(): & mysql_num_rows():


Recommended Posts

I am getting these errors and not sure why and was hoping someone could help?

 

Here are the errors.

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mesquit1/public_html/local/utiles.php on line 109

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mesquit1/public_html/local/utiles.php on line 115

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mesquit1/public_html/local/utiles.php on line 120

Nothing to Display!

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mesquit1/public_html/local/display.php on line 75

 

Here are the lines from utiles.php

 

Line 109

 

 $TotalResults = mysql_num_rows( mysql_query( $Sql ) ); # USE RAW SQL QUERY FOR THIS

 

Line 115

 

 $ResTo   = $From + mysql_num_rows( $RowList );

 

Line 120

 

 "Sample TotalResults  = " . mysql_num_rows( mysql_query( $Sql ) ) . "<br>".

 

 

 

Here is the error from display.php on line 75

 

while ($row = mysql_fetch_array ($result)) {

 

 

If anyone can help me out with this that would be great. I have been looking at this for days and not sure why I am getting this. I am using this same thing on another page and it works fine.

 

-Thanks

Link to comment
https://forums.phpfreaks.com/topic/89020-warning-mysql_fetch_array-mysql_num_rows/
Share on other sites

Here is the complete php for Display.php

 

// Start code for inserting comments

if(isset($_POST['timeout'])) {
    if(time() < $_POST['timeout'])
      unset($_POST);
$firstname = $_POST['firstname'];
$location = $_POST['location'];
$comment_date = date("m-d-Y");
$comment = $_POST['comment'];
$id = $_POST['id'];

// setup our query
$query ="INSERT INTO comments (firstname, location, comment_date, comment, id) VALUES ('$firstname', '$location', '$comment_date', '$comment', '$id')";
                $result=mysql_query($query) or die(mysql_error()); // run our query

// end code for inserting comments
}

// start code for displaying comments

function show_data(){
   $id = array();
   $firstname = array();
   $location = array();
   $comment_date = array();
   $comment = array();
   $id = mysql_real_escape_string($_GET['id']);
   $i=0;
   if(isset($id)) {

$limit          = 5;

{

      $sql = "SELECT * FROM comments WHERE id = $id;";

      $site['url'] = 'http://mesquitechristmas.com/local/display.php?id=$id';
      
      $PageNav = swPagination( $Sql, $MRPP = $limit, $UriAdd = $site['url'], $SortByAllow = FALSE, $SortOrderSeed = FALSE );
      $result = $PageNav['RowList']; #Don't think you need the stuff above

      IF ( !$PageNav['TotalRes'] )  echo("Nothing to Display!");
        $i = 0;
         while ($row = mysql_fetch_array ($result)) {
            $color = ($i%2== 0 || $i == 0)?'#DDDDDD':'#EEEEEE';
            $id[$i] = $row["id"];
            $firstname[$i] = $row["firstname"];
            $location[$i] = $row["location"];
            $comment_date[$i] = $row["comment_date"];
            $comment[$i] = $row["comment"];


print"<tr bgcolor='".$color."'>
    <td align='left' width='120'><strong> Name</strong>: $firstname[$i]</td>
    <td align='left' width='120'><strong> Location</strong>: $location[$i]</td>
    <td align='left' width='216'><strong> Date</strong>: $comment_date[$i]</td>
  </tr>
  <tr bgcolor='".$color."'>
    <td class='commentBorder' colspan='4'><strong> Comment</strong>: $comment[$i]</td>
  </tr>";
      ++$i;
         }
      }
   }
    ECHO $PageNav['HrefNav'];
}

// end code for displaying comments 

cant see this lines:'

Line 109

 

$TotalResults = mysql_num_rows( mysql_query( $Sql ) ); # USE RAW SQL QUERY FOR THIS

 

Line 115

 

$ResTo  = $From + mysql_num_rows( $RowList );

 

Line 120

 

"Sample TotalResults  = " . mysql_num_rows( mysql_query( $Sql ) ) . "<br>".

 

 

 

Here is the error from display.php on line 75

 

while ($row = mysql_fetch_array ($result)) {

cant see this lines:'

Line 109

 

$TotalResults = mysql_num_rows( mysql_query( $Sql ) ); # USE RAW SQL QUERY FOR THIS

 

Line 115

 

$ResTo  = $From + mysql_num_rows( $RowList );

 

Line 120

 

"Sample TotalResults  = " . mysql_num_rows( mysql_query( $Sql ) ) . "<br>".

 

Here is the entire file for those lines starting at line 1

 

<?php
    /**
     * swPaginate( $Sql, $MRPP, $UriAdd, $SortByAllow = FALSE, $SortOrderSeed = FALSE )
     *
     * Short description:
     * Returns an Array of all required paginate values and links
     * This contains all the values and queries to produce
     * paginated links from queries.
     *
     * @by      rr1024
     * @access  public
     * @type    Active  - There are 2 SQL Queries 1 query is passed passively
     * @const   $PageNumDis - +/- Numbers displayed to user 2 will display <First><Prev> 1 2 3 4 <Next><Last>
     * @param   $Sql    -  Primary data row query for display
     * @param   1.1 MOD Not Required X $SqlCnt -  Count all the rows in $Sql
     * @param   $MRPP   -  Maximum Rows Per Page - Defines the total I.E. Results per page
     *             number of results to be displayed per page from $Sql.
     * @param   $UriAdd -  Your pages URI components, it must have URL and URI end in & we will append to this
     * @param   $SortByAllow - Array table list added to query to allow sorting by fields.
     * @param   $SortOrderSeed - String Default is ASC - Allowable is ASC, DESC and RAND but RAND does not function yet.
     * @return  $Paginate Array (
     *             ['RowList'] => You db results list for displaying the data on a page.
     *             ['FromToTotal'] => [OPTIONAL] Display result From n to nn and total results from the ['RowList']
     *             ['PagesNav'] => [OPTIONAL] Display "Pages:"
     *             ['HrefNav'] => html href link to all pages others are provided but not listed
     *                          )
     * @since   1.1
     * @update  01.09.2007
     * @usage   $Sql = "SELECT * FROM `Blog` WHERE `New` = '1' ORDER BY `Date`";
     *          $Uri = $site['url'].'blog_search.php?blog=newblogs&';
     *          $PageNav = swPagination( $Sql, 30, $URI, FALSE, $Order );
     *          $res = $PageNav['RowList'];
     *          WHILE ( $arr = mysql_fetch_array( $res ) ) {
     *               $DataDisplay .= $arr['Name']."<br>";
     *          }
     * @access  ECHO $PageNav['HrefNav'];
     * @depend  dbRes() is my fuctional equivilate to old ae db_res() or standard mysql_query()
    **/
FUNCTION swPagination( $Sql, $MRPP, $UriAdd, $SortByAllow = FALSE, $SortOrderSeed = FALSE )
{

    GLOBAL $site;

      $Paginate   = array(); # Assign output as Array
      $MaxRowsPP  = $MRPP; # Maximum Rows Per Page
      $SqlAdd     = '';
      $PageNumDis = 6; #If 2 Will show <First><Prev> 1 2 3 4 <Next><Last> +/- Integer value 2 before 2 after
      $_GET  = array_map( 'mysql_real_escape_string', $_GET ); // security

        $Page = ( is_numeric( $_GET['page'] ) && $_GET['page'] > 0 ) ? $_GET['page'] : 1;


        $From = ( ( $Page * $MaxRowsPP ) - $MaxRowsPP );



        IF ( $SortOrderSeed != FALSE OR isset($_GET['sortorder']) ) {
             $SortOrderAllow = array( 'ASC', 'DESC', 'RAND' );
             //$SortOrder = ( in_array(strtoupper($_GET['sortorder']), $SortOrderAllow, TRUE) ) ? strtoupper($_GET['sortorder']) : $SortOrderAllow[0];
             $SortTemp = strtoupper( $_GET['sortorder'] );

             IF ( isset( $SortTemp ) ) {

                  IF ( in_array( $SortTemp, $SortOrderAllow, TRUE ) )  {
                       $SortOrder = $SortTemp;
                  }ELSE{
                       $SortOrder = strtoupper( $SortOrderSeed );
                  }

             }ELSE{
                  $SortOrder = $SortOrderSeed;
             }

             IF ( $SortOrder == 'RAND' ) {
                  $SqlAdd = "RAND()";
             }ELSE{
                  $SqlAdd = $SortOrder;
             }

             $SortOrder = strtolower($SortOrder);
             $SortOrderUri = "&sortorder={$SortOrder}";

        }ELSE{
             $SortOrderUri = "&sortorder=asc";
             $SqlAdd .= 'ASC';
        }

        IF ( $SortByAllow != FALSE ) {

             IF ( is_array($SortByAllow) ) {
                  $SortBy = ( in_array($_GET['sortby'], $SortByAllow) ) ? $_GET['sortby'] : $SortByAllow[0];
             }
             $SortByUri = "&sortby={$SortBy}";
             $SqlAdd .= " ORDER BY {$SortBy} ";
        }ELSE{
             $SortByUri = '';
             $SqlAdd = '';
        }

        $Uri = $UriAdd.$PageUri.$SortByUri.$SortOrderUri;


        $RowList = mysql_query( $Sql ." {$SqlAdd} LIMIT $From, $MaxRowsPP" );

        $Paginate['RowList'] = $RowList;  # used outside our function in a while loop to display our results.



        $TotalResults = mysql_num_rows( mysql_query( $Sql ) ); # USE RAW SQL QUERY FOR THIS
        $TotalPages   = ceil( $TotalResults / $MaxRowsPP );
        $Paginate['TotalRes'] = $TotalResults;


        $ResFrom = $From + 1;
        $ResTo   = $From + mysql_num_rows( $RowList );
        # For Testing Only
        $Paginate['test_Paginate'] = "TotalPages   = " . $TotalPages    . "<br>".
                                 "TotalResults = " . $TotalResults  . "<br>".
                                 "Max Rows PP  = " . $MaxRowsPP     . "<br>".
                                 "Sample TotalResults  = " . mysql_num_rows( mysql_query( $Sql ) ) . "<br>".
                                 "SQL Query =" . $Sql ." {$SqlAdd} LIMIT $From, $MaxRowsPP"; # For Testing Only
#===============================================================
#          START PAGINATE OUTPUT ARRAY
#===============================================================

        IF ( $SortByAllow != FALSE ) {

             FOREACH ( $SortByAllow AS $Key => $Value ) {
                       //echo "Key: $Key; Value: $Value<br />\n";
                  $DisplayName = str_replace( "_", " ", $Value );
                  $DisplayName = ucwords( str_replace ( "-", " ", $Value ) );
                  $Paginate['HrefSort_'.$Value] = "<a href ='{$_SERVER['PHP_SELF']}?{$Uri}'>$DisplayName</a>";
                  $Paginate['UriSort_'.$Value]  = $Uri;
             }

             # $Paginate['HrefSortByID']    = "<a href = '{$_SERVER['PHP_SELF']}?page={$Page}&sortby=list_id&sortorder={$SortOrder}'>ID</a>";
             # $Paginate['UriSortByID']     = "{$PageUri}{$SortByUri}{$SortOrderUri}";
             # $Paginate['HrefSortByOrder'] = "<a href = '{$_SERVER['PHP_SELF']}?page={$Page}&sortby=list_order&sortorder={$SortOrder}'>ORDER</a>";
             # $Paginate['UriSortByOrder']  = "{$PageUri}{$SortByUri}{$SortOrderUri}";
             # $Paginate['HrefSortByName']  = "<a href = '{$_SERVER['PHP_SELF']}?page={$Page}&sortby=list_name&sortorder={$SortOrder}'>NAME</a>";
             # $Paginate['UriSortByName']   = "{$PageUri}{$SortByUri}{$SortOrderUri}";
        }

        # Build First and Prev links. If on page 1, we won't make links
        IF ( $Page > 1 ) {
             $prev = ( $Page - 1 );
             $Paginate['HrefNav'] .= "<a href='{$UriAdd}page=1{$SortByUri}{$SortOrderUri}'>First</a><strong> | </strong>";
             $Paginate['UriNav']  .= "[FIRST]{$UriAdd}page=1{$SortByUri}{$SortOrderUri}[/FIRST]";
             $Paginate['HrefFirst']= "<a href='{$UriAdd}page=1{$SortByUri}{$SortOrderUri}'>First</a><strong> | </strong>";
             $Paginate['HrefNav'] .= "<a href='{$UriAdd}page={$prev}{$SortByUri}{$SortOrderUri}'>Prev</a><strong> | </strong>";
             $Paginate['UriNav']  .= "[PREV]{$UriAdd}page={$prev}{$SortByUri}{$SortOrderUri}[/PREV]";
             $Paginate['HrefPrev'] = "<a href='{$UriAdd}page={$prev}{$SortByUri}{$SortOrderUri}'>Prev</a><strong> | </strong>";
        }

        # build the links to the 2 previous and 2 next pages
        FOR ( $i = ($Page - $PageNumDis ); $i <= ( $Page + $PageNumDis ); $i++ ) {
             # only make a link if the prev/next is a valid page number
             IF ( ( $i >= 1 ) && ( $i <= $TotalPages ) ) {
                  $Paginate['HrefNav'] .= ($Page == $i) ? "<strong>[$i]</strong>" : " <a href='{$UriAdd}page=$i{$SortByUri}{$SortOrderUri}'>$i</a> ";
                  $Paginate['UriNav']  .= ($Page == $i) ? "<strong>[$i]</strong>" : "
[PAGE]{$UriAdd}page=$i{$SortByUri}{$SortOrderUri}[/PAGE]
";
                  $Paginate[$i]         = "{$UriAdd}page=$i{$SortByUri}{$SortOrderUri}";
             }
        }

        # Build Next and Last links. If on last page, we won't make a links
        IF ( $Page < $TotalPages ) {
             $next = ( $Page + 1 );
             $Paginate['HrefNav'] .= "<strong> | </strong><a href='{$UriAdd}page={$next}{$SortByUri}{$SortOrderUri}'>Next</a><strong> | </strong>";
             $Paginate['UriNav']  .= "[NEXT]{$UriAdd}page={$next}{$SortByUri}{$SortOrderUri}[/NEXT]";
             $Paginate['HrefNext'] = " | <a href='{$UriAdd}page={$next}{$SortByUri}{$SortOrderUri}'>Next</a><strong> | </strong>";
             $Paginate['HrefNav'] .= "<a href='{$UriAdd}page={$TotalPages}{$SortByUri}{$SortOrderUri}'>Last</a>";
             $Paginate['UriNav']  .= "[LAST]{$UriAdd}page={$TotalPages}{$SortByUri}{$SortOrderUri}[/LAST]";
             $Paginate['HrefLast'] = "<a href='{$UriAdd}page={$TotalPages}{$SortByUri}{$SortOrderUri}'>Last</a>";
        }

        RETURN $Paginate;
}
?>

 

 

 

Seems like you have error in your SQL that you are using in $Sql. check it out.

 

Your observations of the obvious is impeccable, Thank you for pointing that out for your helpful response.

 

 

 

 

 

I can give you a short answer to why you are getting those errors.

 

Some of your mysql_query() function calls are failing (probably due to a sql syntax error or about a half dozen other reasons that prevent the query from running), but your code is not checking if a FALSE value or a valid result resource was returned by the function call before blindly attempting to access the result resource.

 

Some of your mysql_query() statements are checked for query errors, others are not. Your code needs to check the results of every mysql_query() function call to see if it worked or failed before calling a function that references the result resource.

Your observations of the obvious is impeccable, Thank you for pointing that out for your helpful response.

 

No need to be so smug. Your the guy who wasn't aware of the existence of your error in the first place. Now all you need do is figure out how to debug and fix the problem.

 

Good luck.

men that is function.....

we need to see the value of this var  $Sql

 

that is your first parameter in your func.. we need to see it you sql command

 

I have posted ALL of the code for both pages.

 

The entire code for displays.php is in Reply number 2 and the included utiles.php the entire code for that is in Reply 5 as outlined and pointed out which code was which in each thread. So I have posted the ENTIRE code for the issue I am having. If you can not help me with what I have provided then I doubt you can be of assistance to me.

 

No need to be so smug. Your the guy who wasn't aware of the existence of your error in the first place. Now all you need do is figure out how to debug and fix the problem.

 

Wow another person stating the obvious. You are exactly right, I wasn't aware of the existence of my error because I am not fluent in PHP which is why I am here asking for help. If I knew how to fix it do you think I would be here? Geez, the egos of some people here when it comes to helping others simply amaze me.

 

 

 

Is their anyone that can help me with this please?

 

-Thanks

 

 

 

you show us the function.........

we need to see the code where you call that function

 

this is your function

FUNCTION swPagination( $Sql, $MRPP, $UriAdd, $SortByAllow = FALSE, $SortOrderSeed = FALSE )

we need to see the line where you call that func

You'r problem is actually pretty simple. To help you out, you just need to post you SQL QUERY. There is your problem, so that would be something like:

 

$sql = "SELECT * FROM table";

 

Give us the code, and we will help you out. You don't need to get nervous.

Here is the complete php for Display.php

 

// Start code for inserting comments

if(isset($_POST['timeout'])) {
    if(time() < $_POST['timeout'])
      unset($_POST);
$firstname = $_POST['firstname'];
$location = $_POST['location'];
$comment_date = date("m-d-Y");
$comment = $_POST['comment'];
$id = $_POST['id'];

// setup our query
$query ="INSERT INTO comments (firstname, location, comment_date, comment, id) VALUES ('$firstname', '$location', '$comment_date', '$comment', '$id')";
                $result=mysql_query($query) or die(mysql_error()); // run our query

// end code for inserting comments
}

// start code for displaying comments

function show_data(){
   $id = array();
   $firstname = array();
   $location = array();
   $comment_date = array();
   $comment = array();
   $id = mysql_real_escape_string($_GET['id']);
   $i=0;
   if(isset($id)) {

$limit          = 5;

{

      $sql = "SELECT * FROM comments WHERE id = $id;";

      $site['url'] = 'http://mesquitechristmas.com/local/display.php?id=$id';
      
      $PageNav = swPagination( $Sql, $MRPP = $limit, $UriAdd = $site['url'], $SortByAllow = FALSE, $SortOrderSeed = FALSE );
      $result = $PageNav['RowList']; #Don't think you need the stuff above

      IF ( !$PageNav['TotalRes'] )  echo("Nothing to Display!");
        $i = 0;
         while ($row = mysql_fetch_array ($result)) {
            $color = ($i%2== 0 || $i == 0)?'#DDDDDD':'#EEEEEE';
            $id[$i] = $row["id"];
            $firstname[$i] = $row["firstname"];
            $location[$i] = $row["location"];
            $comment_date[$i] = $row["comment_date"];
            $comment[$i] = $row["comment"];


print"<tr bgcolor='".$color."'>
    <td align='left' width='120'><strong> Name</strong>: $firstname[$i]</td>
    <td align='left' width='120'><strong> Location</strong>: $location[$i]</td>
    <td align='left' width='216'><strong> Date</strong>: $comment_date[$i]</td>
  </tr>
  <tr bgcolor='".$color."'>
    <td class='commentBorder' colspan='4'><strong> Comment</strong>: $comment[$i]</td>
  </tr>";
      ++$i;
         }
      }
   }
    ECHO $PageNav['HrefNav'];
}

// end code for displaying comments 

 

 

Like I told you already it is posted in Reply # 2 that I am currently quoting above. I don't know what else you need because I have posted ALL the code associated with this problem.

 

Which is you look very carefully in that code I already posted like I said you will find what you are looking for and you will see this.

 

 $sql = "SELECT * FROM comments WHERE id = $id;";

      $site['url'] = 'http://mesquitechristmas.com/local/display.php?id=$id';
      
      $PageNav = swPagination( $Sql, $MRPP = $limit, $UriAdd = $site['url'], $SortByAllow = FALSE, $SortOrderSeed = FALSE );
      $result = $PageNav['RowList']; #Don't think you need the stuff above

 

 

Anything else?

 

 

I think you are having problem with your query

 

 $sql = "SELECT * FROM comments WHERE id = $id;";

 

Do it like this

 

 $sql = "SELECT * FROM comments WHERE id = '$id'";

 

You have an extra ; in your query and put your $id variable in '$id '

 

Let us know if that was the problem!

$sql = "SELECT * FROM comments WHERE id = '$id'";
         $query = mysql_query($sql);
         $num_rows = mysql_num_ros($query); [color=red][font=Verdana]//Here is numrows now, but you didn't have it before, so I don't see how are you getting an error from this file when you are not using mysql_num_rows. You are probably getting error message from another file[/font][/color]

      $site['url'] = 'http://mesquitechristmas.com/local/display.php?id=$id';
      
      $PageNav = swPagination( $Sql, $MRPP = $limit, $UriAdd = $site['url'], $SortByAllow = FALSE, $SortOrderSeed = FALSE );
      $result = $PageNav['RowList']; #Don't think you need the stuff above

      IF ( !$PageNav['TotalRes'] )  echo("Nothing to Display!");
        $i = 0;
         while ($row = mysql_fetch_array ($result)) {
            $color = ($i%2== 0 || $i == 0)?'#DDDDDD':'#EEEEEE';
            $id[$i] = $row["id"];
            $firstname[$i] = $row["firstname"];
            $location[$i] = $row["location"];
            $comment_date[$i] = $row["comment_date"];
            $comment[$i] = $row["comment"];


print"<tr bgcolor='".$color."'>
    <td align='left' width='120'><strong> Name</strong>: $firstname[$i]</td>
    <td align='left' width='120'><strong> Location</strong>: $location[$i]</td>
    <td align='left' width='216'><strong> Date</strong>: $comment_date[$i]</td>
  </tr>
  <tr bgcolor='".$color."'>
    <td class='commentBorder' colspan='4'><strong> Comment</strong>: $comment[$i]</td>
  </tr>";
      ++$i;
         }
      }
   }
    ECHO $PageNav['HrefNav'];
}

// end code for displaying comments 

 

Can you send me both of this files on my mail? So I can check them out. We are obivously missing something out!

Ok thanks to budimir I have got the errors to go away. I just need to tweak this so it will go to the next page. If you go to.

 

http://www.mesquitechristmas.com/local/display.php?id=2

 

Scroll down to below the comments at the bottom of the page you will see the pagination. Well if you mouse over one of the numbers to go to that page you will notice the URL will be

 

http://www.mesquitechristmas.com/local/display.php?id=$id&page=2&sortorder=asc

 

Look at id=$id where $id is not being shown as the page id like it is in the URL. If you manually set 2 as the id and then manually set the page number in the URL it will go to the next page of comments. So I am not sure how to get the id to show up in the URL of the links. Now if you were to click on one of the numbers it would show this error

 

Unknown column '$id' in 'where clause'

 

This is what I have in the sql

 

$sql = "SELECT * FROM comments WHERE id = '$id' ORDER BY comment_date DESC";

 

      $site['url'] = 'http://www.mesquitechristmas.com/local/display.php?id=$id';

 

Notice I have $id set in the URL and I have played around with it but have not been able to figure this out. Here is the full code for the pagination on this page.

 

// Start code for inserting comments

if(isset($_POST['timeout'])) {
    if(time() < $_POST['timeout'])
      unset($_POST);
$firstname = $_POST['firstname'];
$location = $_POST['location'];
$comment_date = date("m-d-Y");
$comment = $_POST['comment'];
$id = $_POST['id'];

// setup our query
$query ="INSERT INTO comments (firstname, location, comment_date, comment, id) VALUES ('$firstname', '$location', '$comment_date', '$comment', '$id')";
                $result=mysql_query($query) or die(mysql_error()); // run our query

// end code for inserting comments
}

// start code for displaying comments

function show_data(){
   $id = array();
   $firstname = array();
   $location = array();
   $comment_date = array();
   $comment = array();
   $id = mysql_real_escape_string($_GET['id']);
   $i=0;
   if(isset($id)) {

$limit          = 5;

{

      $sql = "SELECT * FROM comments WHERE id = '$id' ORDER BY comment_date DESC";

      $site['url'] = 'http://www.mesquitechristmas.com/local/display.php?id=$id';

      $PageNav = swPagination( $sql, $MRPP = $limit, $UriAdd = $site['url'], $SortByAllow = FALSE, $SortOrderSeed = FALSE );
      $result = $PageNav['RowList']; #Don't think you need the stuff above

      IF ( !$PageNav['TotalRes'] )  echo("Nothing to Display!");
        $i = 0;
         while ($row = mysql_fetch_array ($result)) {
            $color = ($i%2== 0 || $i == 0)?'#DDDDDD':'#EEEEEE';
            $id[$i] = $row["id"];
            $firstname[$i] = $row["firstname"];
            $location[$i] = $row["location"];
            $comment_date[$i] = $row["comment_date"];
            $comment[$i] = $row["comment"];


print"<tr bgcolor='".$color."'>
    <td align='left' width='120'><strong> Name</strong>: $firstname[$i]</td>
    <td align='left' width='120'><strong> Location</strong>: $location[$i]</td>
    <td align='left' width='216'><strong> Date</strong>: $comment_date[$i]</td>
  </tr>
  <tr bgcolor='".$color."'>
    <td class='commentBorder' colspan='4'><strong> Comment</strong>: $comment[$i]</td>
  </tr>";
      ++$i;
         }
      }
   }
    print"<table width='100%'>
                      <tr> 
                        <td> <div align='right'>$PageNav[HrefNav]</div></td>
                      </tr>
                </table>";    
}

// end code for displaying comments

 

 

 

 

 

PHP variables are only parsed when they are in a double-quoted string. Use the first version in budimir's post above, but change the single-quotes to double-quotes.

 

I had tried that already but for some reason I guess i didn't do it right. I tried it again and it works now.

 

So one last question, how can I add an anchor to it so that when you click on a new page it comes back down to the comments. The way it is now you click on a number it goes to the next page but stays at the top instead of going down to the bottom of the page where the commets are.

 

-Thanks

 

 

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.