Jump to content

Recommended Posts

I would assume short tags are not supported and use his 2nd example below.  Also, you don't need a semi colon if its the last line of code before a ?>

 

<?php echo $productid ?> would work just as good.

 

He just forgot the echo

 

<form action="showCart.php?new=<?=$productid; ?>" method="post">

 

or

 

<form action="showCart.php?new=<?php echo $productid; ?>" method="post">

 

the error is probably from forgetting the semi colon.

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429466
Share on other sites

I would assume short tags are not supported and use his 2nd example below.  Also, you don't need a semi colon if its the last line of code before a ?>

 

<?php echo $productid ?> would work just as good.

 

He just forgot the echo

 

<form action="showCart.php?new=<?=$productid; ?>" method="post">

 

or

 

<form action="showCart.php?new=<?php echo $productid; ?>" method="post">

 

the error is probably from forgetting the semi colon.

thanks for ur response but still no joy... syntax errors have gone but its not getting the value of the productid

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429474
Share on other sites

where do you set $productid?

 

function get_product_details($productid)

{

  // query database for all details for a particular product

  if (!$productid || $productid=='')

    return false;

 

    @ $db = mysql_connect('');

    mysql_select_db(');

 

  $query = "select * from products where productid='$productid'";

  $result = mysql_query($query);

  if (!$result)

    return false;

  $result = mysql_fetch_assoc($result);

  return $result;

}

 

function display_product_details($product)

{

  // display all details about this product

  if (is_array($product))

  {

    echo '<table><tr>';

    //display the picture if there is one

    if (@file_exists($product['productid'].'.jpg'))

    {

$myproduct = GetImageSize(($product['productid'].'.jpg'));

 

echo '<img src='.($product['productid']).'.jpg border= '.img_resize($myproduct[0], 

      $myproduct[1], 450).' />';     

 

    }

 

    echo '<td><ul>';

    echo '</li><li><b>Price:</b> £';

    echo number_format($product['price'], 2);

    echo '</li><li><b>Colour:</b> ';

    echo $product['colour'];

    echo '<li><b>Fabric:</b> ';

    echo $product['fabric'];

    echo '</li></ul></td></tr></table>';?>

 

<form action="showCart.php?new=<?php echo $productid ?>" method="post">

    Select size:

    <select name="size">

      <option value=""></option>

      <option value="6">6</option>

      <option value="8">8</option>

      <option value="10">10</option>

      <option value="12">12</option>

        <option value="14">14</option>

    </select> <br/>

Select quantity:

    <select name="quantity">

      <option value="1">1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

    </select>

 

<?php

  }

  else

    echo 'The details of this book cannot be displayed at this time.';

  echo '<hr />';

}

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429492
Share on other sites

please dont post with your database info, can a admin or mod take the database info out please cheers........

 

 

write is the productid in a session..........

 

i still dont see where the productid is set...........

 

my bad im new to this site... ive taken it off... wont happen again

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429510
Share on other sites

I don't see anywhere in the source code you provided where it sets the $productid. Also, next time you post the source code, it would be better to wrap them around with the BB code.

 

$productid = $_GET['productid'];

 

used at start of script after session_start()

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429515
Share on other sites

I don't see anywhere in the source code you provided where it sets the $productid. Also, next time you post the source code, it would be better to wrap them around with the BB code.

 

$productid = $_GET['productid'];

 

used at start of script after session_start()

 

ok ive printed the contents of the variable to see if does actually have  value and it does. Its just not passing on this value on the next page where i render the output in html... so i think that there still a problem in the form action line.... i maybe wrong

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429561
Share on other sites

Thats because you are still not getting any data into $productid.

 

You use both $_GET and $_POST but where do you actually get the $productid from?  It has to come from something.  You use it in your FORM, but what generates it?  You are trying to use a variable that has no data is the problem.

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429577
Share on other sites

Thats because you are still not getting any data into $productid.

 

You use both $_GET and $_POST but where do you actually get the $productid from?  It has to come from something.  You use it in your FORM, but what generates it?  You are trying to use a variable that has no data is the problem.

 

productid does have a value. basically on the previous page a user selects a product and this product is then passed on to the next page where the browser can view more information about the product. so they click the reference link which has the productid appened to the end of the url... so here im using get. so now they come to the show_product page.. here is where they add the product to the cart... at this stage productid has a value but then it does not pass along to the next page which is the showcartpage... ive probably confused u more now sorry

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429583
Share on other sites

Ok, if there is in fact a URL with this info, then $_GET is the right way.

 

Show us the all the code that we're trying to help you with.

 

 

    $url = 'showProduct.php?productid='.($row['productid']);

 

ive created a function where by i have a image and and url link so they can click either. everything works on this page. so then on the next page retriev this value by

  $productid = $_GET['productid'];

 

and this is successful but now when i try agin to pass it on to the page where u add it to the cart its nt passing and i believ its the form action thats causing it

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429592
Share on other sites

Ok, if there is in fact a URL with this info, then $_GET is the right way.

 

Show us the all the code that we're trying to help you with.

 

coding for which page?

    $url = 'showProduct.php?productid='.($row['productid']);

 

ive created a function where by i have a image and and url link so they can click either. everything works on this page. so then on the next page retriev this value by

  $productid = $_GET['productid'];

 

and this is successful but now when i try agin to pass it on to the page where u add it to the cart its nt passing and i believ its the form action thats causing it

Link to comment
https://forums.phpfreaks.com/topic/84325-embedding-php/#findComment-429593
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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