can some one please help me i am getting this error but i cant seem to figure out wat is wrong on line 3 everything looks fine
[PHP]<?php
$conn = mysql_connect("localhost","root","")
or die (mysql_error());
mysql_select_db("Shop_Test",$conn) or die (mysql_error());
$display_block = "<h1> My Store </h1>";
$get_item = "SELECT c.id as Cat_ID, c.cat_title, SI.Item_title,
SI.Item_Price, SI.item_desc, SI.item_Image FROM Store_Items AS SI LEFT JOIN
Store_Categories AS c on c.id =SI.Cat_ID WHERE SI.Store_ID = $_GET[Item_ID]";
$get_item_results = mysql_query ($get_item) or die (mysql_error());
if (mysql_num_rows($get_item_results)<1) {
$display_block .= "<p><em>Invalid item selection.</em></p>";
} else {
$cat_id = mysql_result ($get_item_results,0,'Cat_ID');
$cat_title = strtoupper (stripslashes (
mysql_result ($get_item_results,0, 'cat_title')));
$item_title = stripslashes (mysql_result ($get_item_results,0,'Item_title'));
$item_price = mysql_result ($get_item_results,0,'Item_Price');
$item_desc = stripslashes(mysql_result ($get_item_results,0, 'item_Desc'));
$item_image = mysql_result ($get_item_results,0,'item_Image');
$display_block .= "<p><strong><em> Youre Viewing:</em><br><a href=\"catalogue.php?Cat_ID=$Cat_ID\">$cat_title</a>
> $item_title </strong></p>
<table cellpadding=3 cellspacing=3>
<tr>
<td valign=middle align=center><img src=\"$item_image\"><td>
<td valign=middle><p><strong>Description:</strong><br>$item_desc</p>
<p><strong>Price:</strong> \$$item_price</p>";
$get_colours = "SELECT Item_Colour FROM Store_Item_Colour WHERE
Store_ID = $item_id ORDER BY Item_Colour";
$get_colour_results = mysql_result ($get_colours) or die (mysql_error());
if (mysql_num_rows($get_colour_results)>0) {
$display_block .= "<p><strong>Available Colours:</strong><br>";
while ($colours = mysql_fetch_array($get_colour_results)) {
$item_colour = $colours['Item_Colour'];
$display_block .= "item_colour<br>";
}
}
$get_sizes = "SELECT Item_size FROM store_item_size WHERE
Store_ID = $item_id ORDER BY Item_size";
$get_size_results = mysql_query($get_sizes) or die (mysql_error());
if (mysql_num_rows ($get_size_results)>0) {
$display_block .= "<p><strong>Available Sizes:</strong></br>";
while ($sizes = mysql_fetch_array ($get_size_results)) {
$item_size = $sizes ['Item_size'];
$diplay_block .= "$item_size<br>";
}
}
$display_block .= "
</td>
</tr>
</table>";
}
?>[/PHP]
Please help i have to do a project thanks in advance
6 2018
Hi,
I've had a look over the code and I assume the first SQL is the one with the problem. Is that the case? If so then the following may be of help, if not then it's probably no good to you.
You have:
[php]
$get_item = "SELECT c.id as Cat_ID, c.cat_title, SI.Item_title,
SI.Item_Price, SI.item_desc, SI.item_Image FROM Store_Items AS SI LEFT JOIN
Store_Categories AS c on c.id =SI.Cat_ID WHERE SI.Store_ID = $_GET[Item_ID]";
[/php]
I have never managed to make the use of the $_GET array work directly in a SQL statement like that. So I would try:
[php]
$lnItemID = $_GET['Item_ID'] ;
$get_item = "SELECT c.id as Cat_ID, c.cat_title, SI.Item_title,
SI.Item_Price, SI.item_desc, SI.item_Image FROM Store_Items SI LEFT OUTER JOIN
Store_Categories c on c.id = SI.Cat_ID WHERE SI.Store_ID = $lnItemID";
[/php]
The other changes are just personal preferences but whenever I use that syntax it works first time.
The other potential issue I spotted was that you are not passing a link identifier (defined at the top of your code as $conn) to the mysql_query - this needs to be the second parameter.
I hope this helps you out.
nathj
The other potential issue I spotted was that you are not passing a link identifier (defined at the top of your code as $conn) to the mysql_query - this needs to be the second parameter.
No entirely true. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. See php documentation.
Ronald
Thanks Nathj for ur reply but i had no luck with the new code still coming up with the same error. any other suggestions everything seems fine ive been sifting through the code up and down but cant seem to find the error.
please help i need to complete this for my project.
The following gets rid of the MySQL error in line 3: - $get_item = "SELECT c.id as Cat_ID, c.cat_title, SI.Item_title, SI.Item_Price, SI.item_desc, SI.item_Image
-
FROM Store_Items AS SI
-
LEFT JOIN Store_Categories AS c on c.id =SI.Cat_ID
-
WHERE SI.Store_ID = '{$_GET['Item_ID']}'";
Ronald
Thanks once again ronald. uve been a great help
You are welcome, until next time.
Ronald
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dracolytch |
last post by:
Good day all,
Ok, I have a pretty tricky problem that I need some help with.
I pass around search query information a fair amount (specifically
WHERE statements). Normally, I just rawurlencode()...
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much...
|
by: Gary |
last post by:
Hi,
I get this error " "
when my web page run,
what does it mean?
Hope someone can help!!!
Gary
|
by: caveman |
last post by:
Hi i am using PHP to upload picture files to a file in my server, but for some reason it will not create thumbnails of the upload, all that happens is that where the thumbnail is meant to be...
|
by: valeberry |
last post by:
index
<?php
include ("conn.php");
require_once("tabs.php");
?>
<html>
<head>
<?php tabs_header(); ?>
</head>
<body>
|
by: bimeldip |
last post by:
Hi,
I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
|
by: Leena P |
last post by:
i want to basically take some information for the product and let the user
enter the the material required to make this product
1.first page test.php
which takes product code and displays...
|
by: bimeldip |
last post by:
Hi,
I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
|
by: RYKLOU |
last post by:
I am kinda new to php, but i do know what i am doing kinda, but i came across this error when i am trying to upload a file to my website.
Fatal error: Allowed memory size of 8388608 bytes...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |