justlukeyou
-
Posts
957 -
Joined
-
Last visited
Posts posted by justlukeyou
-
-
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'];
-
So I take it the idea of putting width=\"80%\" in wont work then lol
-
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
-
Hi,
It just comes up with the following 'error' its as if it doesn't know what string to query so doesn't bring back any results.
query: SELECT * FROM productfeed WHERE description = LIMIT 0, 10
-
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>
-
I am looking to resize images from a database and found this guide. It looks relatively simple. Is this the easiest method of resizing images.
http://articles.sitepoint.com/article/image-resizing-php
-
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>£ $price</center> </div> <div class='productbuybutton'> <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center> </div> </div> </div>"; } ?>
-
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>£ $price</center> </div> <div class='productbuybutton'> <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center> </div> </div> </div>"; } ?>
-
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>&#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(); } ?>
-
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();}
-
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>£ $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>"; }
-
Hi,
I put fetchdata: $fetchdata<br>Failed with error: " . mysql_error() . '<br> because apart from the CSS I was just getting a white screen so I had to do something.
-
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>£ $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(); } ?>
-
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.
-
I tried it and without the "?id=3" ir reads $_GET['id'] is NOT set, or is NOT numeric.
When I try it with "?id=3" I still get just the CSS.
Could this mean that my db is set up wrong in some way?
-
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>£ $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>"; }
-
Thanks, I thought I did that in my link when I search for the item:
(example.com/ProductFeed/phpproductfeed.php?id=1)
How do I assign it a value in the code?
-
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>£ $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>"; } ?>
-
Hi,
It works a treat now, many thanks.
-
Thats a good question. I shall take it out.
-
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>&#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"; } ?>
-
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>&#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"; } ?>
-
Hi,
Is my code inefficient? Im a bit lost as to how I can make it more effective.
If I am just printing everything in a database do I not need to use a loop?
-
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>£ $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>"; } }
Only Shows 'Description' (Numbers?)
in PHP Coding Help
Posted
Hi,
Thanks I have tried this but it does something a bit unusual.
I have the description in a line text. For example "Red Widget" and "Blue Widget" but instead of showing "Red Widget" it has changed all the descriptions to "Description".