0

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.

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by bjg5858
0

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?

0

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

echo "<select name='type'>";
include("mysql_conn.php");
include("db_conn.php");

// Get a specific result from the "type" table
$result = mysql_query("SELECT * FROM type") or die(mysql_error());

while($row = mysql_fetch_array( $result )) {
$type = $row['type'];
echo  "<option value=$type>$type</option>";
}
echo "</select>";

Here is a some code from the processing form which adds user input to the database;

$prod_type = $_POST['type'];

$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')";
$result = @mysql_query($qry);
0
echo "<select name='type'>";
include("mysql_conn.php");
include("db_conn.php");

// Get a specific result from the "type" table
$result = mysql_query("SELECT * FROM type") or die(mysql_error());

while($row = mysql_fetch_array( $result )) {
$type = $row['type'];
echo  "<option value=$type>$type</option>";
}
echo "</select>";

I think the problem might be here, try enclosing the value attribute for the select statement in quotes:

while($row = mysql_fetch_array( $result )) {
$type = $row['type'];
echo  "<option value=\"$type\">$type</option>";
}

Another thing you can try is, on the page that you post this form to, at the top:

echo "<pre>";
print_r($_POST);
echo "</pre>";
die();

Which will tell exactly what is coming through from your form.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.