Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5

Thread: [PHP] Help

  1. #1
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default [PHP] Help

    Hey,

    I am makeing an online catalog for my dads company. However im haveing some issues, I am getting errors when trying to split it up, Can you guys have a look and see if you can fix it.

    Code:
    PHP Code:
    <?php
    // List Products
    include("config.php");
    $cet_idd $_GET['categorie'];
    if(
    $cet_idd == "1"){
    $name "<font class='top_name'><u>TIG AC/DC</u></font><br><br>";
    }elseif(
    $cet_idd == "2"){
    $name "<font class='top_name'><u>TIG DC</u></font><br><br>";
    }elseif(
    $cet_idd == "3"){
    $name "<font class='top_name'><u>MIG MAG Welding</u></font><br><br>";
    }elseif(
    $cet_idd == "4"){
    $name "<font class='top_name'><u>Plasma</u></font><br><br>";
    }elseif(
    $cet_idd == "5"){
    $name "<font class='top_name'><u>MMA Arcwelding</u></font><br><br>";
    }elseif(
    $cet_idd == "6"){
    $name "<font class='top_name'><u>Chargers</u></font><br><br>";
    }else{
    $name "Please selece a catorgire.";
    }
    echo 
    "$name";

    if(
    $name != "Please selece a catorgire."){
    $result mysql_query("SELECT * FROM products WHERE cat_id = '$cet_idd'");
    if(
    mysql_fetch_array($result) == 0){
    echo 
    "This catogrie currently has no items in it.";
    mysql_close();
    }else{
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    /////////////////////////////////////////////////
    $pagess $_GET['page'];
    $resultsperpage // this is how many results you want to show per page 
    $pg max(intval($pagess )); // if they did not requst page, they are on page 1 
    $aadsa intval(($pg -1)*$resultsperpage);
    $query "SELECT * FROM products WHERE cat_id = '$cet_idd' LIMIT '$aadsa' , $resultsperpage"
    $res mysql_query ($query) ; 
    // this is your total number of items with no regards to LIMIT in the query 
    // doing query over just to get this number is pointless 
    $found_count mysql_result (mysql_query ("SELECT FOUND_ROWS() ") , ) ; 
    // now you loop over your results      
    $products '' ;         
    while (
    $row mysql_fetch_assoc ($res) ) { //do something with your products here 
     
    $id $row["id"];
     
    $prod_id $row["prod_id"];
     
    $prod_name $row["prod_name"];
     
    $prod_dis $row["prod_dis"];
     
    $url $row["URL"];
     
    $prod_offer_text $row["prod_offer_text"];
     
    $prod_offer_price $row["prod_offer_price"];
     
    $prod_price $row["prod_price"];
    // 
    if($prod_offer_text == ""){
    $new_offer_text "";
    }else{
    $new_offer_text "$prod_offer_text";
    }
    if(
    $prod_offer_text || $prod_offer_price != ""){
    $price "<STRIKE>&pound;$prod_price</STRIKE> - &pound;$prod_offer_price";
    }else{
    $price "&pound;$prod_price";
    }
    echo 
    "<table width='100%' cellpadding='0' cellspacing='0'>";
    echo 
    "
      <tr>
        <td width='13%' rowspan='3' align='center' valign='top'><a href='?view=view_products&&id=
    $prod_id'><img src='$url' width='150' height='150' border='0'></a></td>
        <td colspan='3'><font class='product_name'><b>&nbsp;&nbsp;#
    $prod_id - $prod_name</b></font></td>
      </tr>
      <tr>
        <td height='96' colspan='3' valign='top'><br>
    $prod_dis<br></td>
      </tr>
      <tr>
        <td width='59%' height='33'><font class='product_offer'>&nbsp;&nbsp;
    $new_offer_text</font></td>
        <td width='23%'><font class='product_price'>
    $price</font></td>
        <td width='5%' align='right'><a href='?view=view_products&&id=
    $prod_id'>More?</a></td>
      </tr>
    "
    ;
    echo 
    "</table><hr><br>";
    //////////////////
    ////////////////////
    //////////////////
    /////////////////
    //     $products .= $r['name'] ."<br>" ; 
    }}}
    if (!
    $products) { 
         
    //there were no products , do something about it 
      
    echo "error";

    // here are simple pagination links 
    $pages '';         
    for (
    $i=$i <= ceil($found_count $resultsperpage) ; $i++  ) { 
          
    $pages .= '<a href="products.php?pg='.$i.'">'.$i.'</a>'
    }
    // $pages string now has your navigation in it 
    ?>
    Error:
    Warning: Wrong parameter count for max() in /home/master/public_html/...... on line 38

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/master/public_html/...... on line 49
    error
    Danny


  2. #2
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Well the SQL error is because:
    it needs to be LIMIT BY 0,1 or something similar:
    Code:
    LIMIT BY $aadsa,$resultsperpage
    And the parameter count for max is wrong because you haven't put enough of these or too many. I haven't had a look at your code.:

    PHP Code:
    max('one','two','three'
    Last edited by Florx; 08-02-2008 at 10:29 PM.

  3. #3
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Quote Originally Posted by FlorX View Post
    Well the SQL error is because:
    it needs to be LIMIT BY 0,1 or something similar:
    Code:
    LIMIT BY $aadsa,$resultsperpage
    And the parameter count for max is wrong because you haven't put enough of these or too many. I haven't had a look at your code.:

    PHP Code:
    max('one','two','three'
    No, as $aadsa and $resultsperpage are obviously set to like 10 or 21

  4. #4
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    I got another Error

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/master/public_html/..... on line 14
    Some of the code:
    PHP Code:
    $sql mysql_query("SELECT * FROM products WHERE cet_idd = '$cet_idd' LIMIT $start_from$datashow");
    // Start
    while ($row mysql_fetch_row($sql)) { //do something with your products here 
     
    $id $row["id"];
     
    $prod_id $row["prod_id"];
     
    $prod_name $row["prod_name"]; 
    (Line 14 is in there (first Line))


  5. #5
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    LIMIT BY whatever,whatever

    and @BLOB that's what I meant :p

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •