Get support from Xavier Media
It is currently Sun Dec 08, 2013 12:25 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: HELP with PHP/SQL
PostPosted: Sun Jan 27, 2008 10:07 pm 

Points:
:?
Hi,
I'm a newbie to PHP and I've been struggling with this for a VERY long time now. I finally found a way to retrieve the product ID from the previous page. But, now I need to take the product ID I retrieved and echo out to the page the product Name associated with the product ID.

Here is what I've come up with so far, but it is giving me an error, that it does not recognize "$productId". So, what many things am I doing wrong?


<?php
$productId = $_GET['prodId'];
$results = mysql_query("SELECT product_Name,
FROM tbl_products
WHERE product_ID = $productId"); //This is where I think I'm going wrong.
echo $results;
?>


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: Tue Jan 29, 2008 6:36 pm 

Points:
To start you have a comma directly after product_Name, in your code.

It would help if you could post the actuall error message you get.

/Andreas


Report this post
Top
  
Reply with quote  
 Post subject: HELP with PHP/SQL
PostPosted: Thu Jan 31, 2008 6:29 am 

Points:
First, thank you for replying. Your help is sooo needed. I modified some since my post, this is what I have so far:

<?php
if (isset($_GET['prodId'])) {
$productId = $_GET['prodId'];
// echo $productId;
$query = mysql_query("SELECT product_MerchantProductID,
product_Name
FROM tbl_products
WHERE product_ID = %s", $productId) or die(mysql_error());
$row = mysql_fetch_array( $result );
echo $row['prodId']." - ".$row['prodName'];
}
?>

And, I am getting nothing. Nothing is being retrieved, and there is no error message.

I'm using Cartweaver, a shopping cart program.

I was able to pass the productId through, head (Location: orderForm.php?prodID=" . $productId) and retrieving it in my new for via;
$productId = $_GET['prodId'];
echo $productId;

But now, I can't seem to convert $productId to retrieve from SQL the product_Name and product_MerchantProductID FROM the tbl_products.

It would help if I could figure out how to interpret SQL query that Cartweaver is using. This is their SQL statement;

/* Get Product Data */
$query_rsCWGetProduct = sprintf("SELECT product_ID,
product_Name,
product_Description
FROM
tbl_products
WHERE product_ID = %s
AND product_Archive = 0
AND product_OnWeb = 1", $productId);
$rsCWGetProduct = $cartweaver->db->executeQuery($query_rsCWGetProduct, "rsCWGetProduct");
$rsCWGetProduct_recordCount = $cartweaver->db->recordCount;
$row_rsCWGetProduct = $cartweaver->db->db_fetch_assoc($rsCWGetProduct);

It would help if I knew how to interpret the query to modify it to my form.

I hope you can guide me to the right direction..


Report this post
Top
  
Reply with quote  
 Post subject: Re: HELP with PHP/SQL
PostPosted: Fri Sep 26, 2008 5:37 am 
Offline
Rookie (I'm probably spamming)
Rookie (I'm probably spamming)

Joined: Fri Sep 26, 2008 5:17 am
Posts: 1
Points: 0
In SQL everything is done in a "query". Personally I think this must be because somebody got the idea that since it's a query language, everything must be a query, and made it so even if it's an instruction like "add this record". That would be an insert query! Ah well, if I want to be a master of SQL I will have to toe the line an accept the expanded notion of "queries"! More about them later -- first, lets take a look at the most common commands you'll see.

--------------
Nikimathew
viral and buzz marketing


Report this post
Top
 Profile Send private message E-mail  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Registered users: No registered users


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]