943,680 Members | Top Members by Rank

Ad:
Jul 14th, 2009
0

problem with $_post

Expand Post »
I have a form which takes a string from a database and posts it to another page problem is that post seems to be shortening the variable.

So if post should be "product name" it is shortened to "product" by post I think.

Any help would be great thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bjg5858 is offline Offline
10 posts
since Nov 2007
Jul 15th, 2009
0

Re: problem with $_post

Hi there,
Is "product name" the name of the input box & post variable or is that the value of the variable/text in the input box?
Reputation Points: 49
Solved Threads: 22
Junior Poster
Menster is offline Offline
175 posts
since Jun 2009
Jul 15th, 2009
0

Re: problem with $_post

Here is the real code "product name" was just an example.
This is the part of the input form;

HTML and CSS Syntax (Toggle Plain Text)
  1. echo "<select name='type'>";
  2. include("mysql_conn.php");
  3. include("db_conn.php");
  4.  
  5. // Get a specific result from the "type" table
  6. $result = mysql_query("SELECT * FROM type") or die(mysql_error());
  7.  
  8. while($row = mysql_fetch_array( $result )) {
  9. $type = $row['type'];
  10. echo "<option value=$type>$type</option>";
  11. }
  12. echo "</select>";
Here is a some code from the processing form which adds user input to the database;
HTML and CSS Syntax (Toggle Plain Text)
  1. $prod_type = $_POST['type'];
  2.  
  3. $qry = "INSERT INTO products(prod_name, prod_desc, prod_skincond, prod_application, prod_benefits, prod_type, prod_price, prod_img, prod_size, prod_code) VALUES('$prod_name','$prod_desc','$prod_skincond','$prod_application','$prod_benefits','$prod_type','$prod_price','$img','$prod_size','$prod_code')";
  4. $result = @mysql_query($qry);
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bjg5858 is offline Offline
10 posts
since Nov 2007
Jul 15th, 2009
0

Re: problem with $_post

Click to Expand / Collapse  Quote originally posted by bjg5858 ...
HTML and CSS Syntax (Toggle Plain Text)
  1. echo "<select name='type'>";
  2. include("mysql_conn.php");
  3. include("db_conn.php");
  4.  
  5. // Get a specific result from the "type" table
  6. $result = mysql_query("SELECT * FROM type") or die(mysql_error());
  7.  
  8. while($row = mysql_fetch_array( $result )) {
  9. $type = $row['type'];
  10. echo "<option value=$type>$type</option>";
  11. }
  12. echo "</select>";
I think the problem might be here, try enclosing the value attribute for the select statement in quotes:
php Syntax (Toggle Plain Text)
  1. while($row = mysql_fetch_array( $result )) {
  2. $type = $row['type'];
  3. echo "<option value=\"$type\">$type</option>";
  4. }

Another thing you can try is, on the page that you post this form to, at the top:
php Syntax (Toggle Plain Text)
  1. echo "<pre>";
  2. print_r($_POST);
  3. echo "</pre>";
  4. die();
Which will tell exactly what is coming through from your form.
Reputation Points: 49
Solved Threads: 22
Junior Poster
Menster is offline Offline
175 posts
since Jun 2009
Jul 15th, 2009
0

Re: problem with $_post

All variables have a limit on the legth of values it can hold. If you are using Joomla or another CMS then often restrictions are placed and you can only post values using the methods designated in the API.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
kronikmedia is offline Offline
65 posts
since May 2008
Jul 16th, 2009
0

Re: problem with $_post

Thanks Menster Adding the quotes fixed the problem.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bjg5858 is offline Offline
10 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Create fields using <option> tags
Next Thread in HTML and CSS Forum Timeline: how do thay get twitter id to show up in link?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC