Jump to content

justlukeyou

Members
  • Posts

    957
  • Joined

  • Last visited

Posts posted by justlukeyou

  1. Thanks,

     

    I now have the following code.  When I use this as my link:

     

    phpdescriptionresults.php?description=Description

     

    it displays everything in my database. But if I try:

     

    phpdescriptionresults.php?description=Descriptionproduct

     

    It comes up with the following error:

     

    query: SELECT * FROM productfeed WHERE description = Descriptionproduct

    This has an error: Unknown column 'Descriptionproduct' in 'where clause'

     

    I am setting the only output to description?

     

    <?php
    if (isset($_GET['description']))
    $query = "SELECT * FROM productfeed WHERE description = $description";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];

  2. Thanks,

     

    I tried that but it still keeps up with the same message.

     

    When I was using the idea number it was working fine but when I try to use the same principal on other strings it doesn't work. 

     

    Previously I had this

     

    $query = "SELECT * FROM productfeed WHERE id = $id";

        --------> id1

     

    $query = "SELECT * FROM productfeed WHERE description = $description

      --------> I dont want the first description to be in place but everything I try just comes back with the message

     

    query: SELECT * FROM productfeed WHERE description = description LIMIT 0, 10

     

     

  3. Thanks, I thought I could just resize the image inside the css div I already by using the standard image width function.  But this has no affect but I dont understand why.

     

    <div class='productborder'>
    <a href='$link' target='_blank' width=\"80%\" ><img src='$image'/></a>
    </div>

  4. Thanks,

     

    I have tried the following but it just brings up an error regardless of what I search.  I have not tried to define it anywhere.

     

    <?php
    $query = "SELECT * FROM productfeed WHERE $description =  LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    
    
    
    echo "<div class='productdisplayshell'>
    <div class='productdisplayoutline'>
    <div class='productborder'><center>
    <a href='$link' target='_blank'><img src='$image'/></a>
    </center> </div></div>
    <div class='productdescriptionoutline'>
    <div class='productdescriptionbox'>
    <a href='$link' target='_blank' >$description</a>
    </div>
    <div class='productfulldescriptionbox'>$fulldescription</div>
    </div>
    <div class='productpriceoutline'>
    <div class='productpricebox'>
    <center>&#163; $price</center>
    </div>
    <div class='productbuybutton'>
    <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center>
    </div>
    </div>
    </div>";
    } 
    ?>
    

  5. I set up the following code to successfully individual items based on the id number. ?id=1 etc.  However, I thought it would be simple to change to show another row so I changed all the terms to 'description'.  However, if I enter ?description=abcde it shows nothing.  But if I type in ?description=description is bizarrely shows everything.

     

    The only thing I can only put it down to is numbers.  Does $_GET react differently react differently to numbers or does it require commas surrounding the string?

     

     

    
    <?php
    if( isset($_GET['description']))
    $_GET['description'];
    $query = "SELECT * FROM productfeed WHERE description = $description LIMIT 0, 10";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    
    
    
    echo "<div class='productdisplayshell'>
    <div class='productdisplayoutline'>
    <div class='productborder'><center>
    <a href='$link' target='_blank'><img src='$image'/></a>
    </center> </div></div>
    <div class='productdescriptionoutline'>
    <div class='productdescriptionbox'>
    <a href='$link' target='_blank' >$description</a>
    </div>
    <div class='productfulldescriptionbox'>$fulldescription</div>
    </div>
    <div class='productpriceoutline'>
    <div class='productpricebox'>
    <center>&#163; $price</center>
    </div>
    <div class='productbuybutton'>
    <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center>
    </div>
    </div>
    </div>";
    } 
    ?>

  6. Hi, brilliant thanks for your help.  With the code it came up an $end error so I removed the invalid part line and then add another curly so it just presented the product but if I searched for an ID not in my database it did not give a message.  So I added a previous an echo message however this shows permanently.  So it shows the product and then below it says that there are now ids available within the database.  Hopefully I can get the not available line to work and then I should be there.

     

    This forum is great.

     

    <?php
    if( isset($_GET['id']) && ctype_digit($_GET['id']) ) { // validate that $_GET['id'] is set, and contains only numeric characters
    $id = (int) $_GET['id']; // cast value as an integer, and assign to $id
    $query = "SELECT * FROM productfeed WHERE id = $id";
    $fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error() . '<br>');
    while($row = mysql_fetch_array($fetchdata)) {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    echo "<div class='productdisplayshell'>
    <div class='productdisplayoutline'>
    <div class='productborder'><center>
    <a href='$link' target='_blank'><img src='$image'/></a>
    </center> </div></div>
    <div class='productdescriptionoutline'>
    <div class='productdescriptionbox'>
    <a href='$link' target='_blank' >$description</a>
    </div>
    <div class='productfulldescriptionbox'>$fulldescription</div>
    </div>
    <div class='productpriceoutline'>
    <div class='productpricebox'>
    <center>&#38;#163; $price</center>
    </div>
    <div class='productbuybutton'>
    <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center>
    </div>
    </div>
    </div>";
    } 
    echo 'Product is not available.  Please visit our <a href="http://www.domain.co.uk">Homepage</a>';exit();
    }
    
    ?>

  7. Hi,

     

    It turned this into an error.  But Im really struggling with getting the data to appear.  It appears without the $_GET['id'.  I'm finding it like spinning plates but the help on this forum is a massive help.

     

    else {echo 'Product is not available.  Please visit our <a href="http://www..co.uk">Homepage</a>';exit();} 

  8. hi BlueSky,

     

    I tried your code however it comes up with error: "Failed with error" which relates the first echo.

     

    It also kicked out the else loop I had at the end which gives a message if the id is not in the database.    Is there a standard method of doing _GET?

     

    <?php
    if( isset($_GET['id']) && ctype_digit($_GET['id']) ) { // validate that $_GET['id'] is set, and contains only numeric characters
    $id = (int) $_GET['id']; // cast value as an integer, and assign to $id
    $query = "SELECT * FROM productfeed WHERE id = $id";$fetchdata = mysql_query($query) or die("query: $query<br>This has an error: " . mysql_error()  . '<br>');if (!$fetchdata);
    echo "query: $query<br>Failed with error: " . mysql_error()  . '<br>';
    } else {
    while($row = mysql_fetch_array($fetchdata))
    
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    
    
    echo "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center> <a href=\"$link\" target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\"> <a href=\"$link\" target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\"> $fulldescription </div></div> <div class=\"productpriceoutline\"> <div class=\"productpricebox\"><center>&#163; $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>";
    
    
    
    } 

     

     

     

  9. Hi,

     

    I have the following code which I have been able to put together with alot of the brilliant help on this forum.  When I run this code it just came up with a blank screen and the CSS however I added another error print "echo "fetchdata: $fetchdata<br>Failed with error: " . mysql_error()  . '<br>';" and the result now is "fetchdata: Resource id #2".

     

    However, when search for this on Google many of the responses data back from between 2002-2006.  Does it just mean that there is an error with the second if query or does  Resource id #2 refer to a specific error? Im really puzzled why I cant find anything more modern to this error on Google.

     

    <?php
    if( isset($_GET['id']) && ctype_digit($_GET['id']) ) { // validate that $_GET['id'] is set, and contains only numeric characters
    $id = (int) $_GET['id']; // cast value as an integer, and assign to $id
    $query = "SELECT * FROM productfeed WHERE id = $id";
    if( !$fetchdata = mysql_query($query) ) { // numeric values shouldn't be quoted in query strings.
    echo "query: $query<br>Failed with error: " . mysql_error()  . '<br>';
    } else {
    while($row = mysql_fetch_array($fetchdata))
    
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    
    
    echo "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center> <a href=\"$link\" target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\"> <a href=\"$link\" target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\"> $fulldescription </div></div> <div class=\"productpriceoutline\"> <div class=\"productpricebox\"><center>&#163; $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>";
    
    echo "fetchdata: $fetchdata<br>Failed with error: " . mysql_error()  . '<br>';
    
    }
    } else {
    echo 'Product is not available.  Please visit our <a href="http://www.ukhomefurniture.co.uk">Homepage</a>';
    exit();
    } 
    
    ?>

  10. I see so if some adapts the search, the message comes up.

     

    Im using a tuturial from YouTube from my iPhone, the video does include the else option to display messages if products aren't available but it does put numeric values in brackets.

     

    It also sanitises the id but comes up with lots of errors.

     

    I cant see why it now gives me a white screen though.

  11. Thanks, this is my code now but I have a white screen of death without any errors:

     

    <?php
    
    if( isset($_GET['id']) && ctype_digit($_GET['id']) ) { // validate that $_GET['id'] is set, and contains only numeric characters
    $id = (int) $_GET['id']; // cast value as an integer, and assign to $id
    $sql = mysql_query("SELECT * FROM productfeed WHERE id = $id LIMIT 1"); // numeric values shouldn't be quoted in query strings.
    
    while($row = mysql_fetch_array($sql))
    
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    echo "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center>  <a href=\"$link\"  target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\">  <a href=\"$link\"  target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\">  $fulldescription </div></div> <div class=\"productpriceoutline\">  <div class=\"productpricebox\"><center>&#163; $price</center></div>  <div class=\"productbuybutton\"><center><a href=\"$link\"  target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>";
    
    } 
    
    
    
    

     

  12. I am trying to do isset($_GET but I have a bizarre problem come up.  I am using "id" as one of my fields but when I try to use it in the code it says it is not recognised.  However I use this field quite widely.

     

    The code its coming up with is "Undefined variable: id" but I cant see why it has a problem with id.

     

    My code is:

     

    <?php
    
    if(isset($_GET['id'])){
    
    $sql = mysql_query("SELECT * FROM productfeed WHERE id='$id' LIMIT 1");
    
    }
    {
    
    
    while($row = mysql_fetch_array($sql))
    
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    echo "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center>  <a href=\"$link\"  target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\">  <a href=\"$link\"  target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\">  $fulldescription </div></div> <div class=\"productpriceoutline\">  <div class=\"productpricebox\"><center>&#163; $price</center></div>  <div class=\"productbuybutton\"><center><a href=\"$link\"  target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>";
    
    } 
    
    
    
    
    ?>

  13. Hi, I added those to get rid of the error it came up with.

     

    This is the error "Parse error: syntax error, unexpected $end in".

     

    This is all the code on my page which creates the error above:

     

    <?php
    
    ***PASSWORD LOGIN***
    
    $result = mysql_query("SELECT * FROM productfeed LIMIT 0, 2");
    
    
    while($row = mysql_fetch_array($result))
    {
    $id = $row['id'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    ?>
    
    <?php
    $result = mysql_query("SELECT * FROM productfeed LIMIT 2");
    while( $row = mysql_fetch_array($result) ) {
    $id = $row['ID'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    echo "<div class=\"productdisplayshell\">\n
    <div class=\"productdisplayoutline\">\n
    <div class=\"productborder\">
    <center><a href=\"$link\" target=\"_blank\" ><img src=\"$image\" /></a></center>\n
    </div>\n
    </div>\n
    <div class=\"productdescriptionoutline\">\n
    <div class=\"productdescriptionbox\">\n
    <a href=\"$link\" target=\"_blank\" >$description</a>\n
    </div>\n
    <div class=\"productfulldescriptionbox\">$fulldescription\n
    </div>\n
    </div>\n
    <div class=\"productpriceoutline\">\n
    <div class=\"productpricebox\">\n
    <center>&#38;#163; $price</center>\n
    </div>\n
    <div class=\"productbuybutton\">\n
    <center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center>\n
    </div>\n
    </div>\n
    </div>\n";
    }
    
    ?>
    

  14. Hi,

     

    I tried but it comes with an error straight away on the first "<" I put some curly tags in and now it comes up with an error for an unexpected end.  With my previous code does it have an error with an error because of the curly tags?

     

    <?php
    
    ***DATABASE LOG IN SECTION***
    
    $result = mysql_query("SELECT * FROM productfeed LIMIT 2");
    {
    while( $row = mysql_fetch_array($result) ) {
    $id = $row['ID'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    ?>
    
    
    <?php
    echo 
    "<div class=\"productdisplayshell\">\n
    <div class=\"productdisplayoutline\">\n
    <div class=\"productborder\">
    <center><a href=\"$link\" target=\"_blank\" ><img src=\"$image\" /></a></center>\n
    </div>\n
    </div>\n
    <div class=\"productdescriptionoutline\">\n
    <div class=\"productdescriptionbox\">\n
    <a href=\"$link\" target=\"_blank\" >$description</a>\n
    </div>\n
    <div class=\"productfulldescriptionbox\">$fulldescription\n
    </div>\n
    </div>\n
    <div class=\"productpriceoutline\">\n
    <div class=\"productpricebox\">\n
    <center>&#38;#163; $price</center>\n
    </div>\n
    <div class=\"productbuybutton\">\n
    <center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center>\n
    </div>\n
    </div>\n
    </div>\n";
    }
    ?>

  15. Hi, this is:

     

    $result = mysql_query("SELECT * FROM productfeed LIMIT 2");
    
    
    while($row = mysql_fetch_array($result))
    {
    $id = $row['ID'];
    $image = $row['awImage'];
    $link = $row['link'];
    $description = $row['description'];
    $fulldescription = $row['fulldescription'];
    $price = $row['price'];
    
    
    ?>
    
    
    
    <?php
    
    {
    
    
    echo   "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center>  <a href=\"$link\"  target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\">  <a href=\"$link\"  target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\">  $fulldescription </div></div> <div class=\"productpriceoutline\">  <div class=\"productpricebox\"><center>&#163; $price</center></div>  <div class=\"productbuybutton\"><center><a href=\"$link\"  target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>";
    
    
    }
    }

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