I am new to PHP but have been using it for about a week. I'm having no trouble using html forms to recall data from a MySQL table when the input type=text but i cant seem to find a way of recalling the data from the MySQL table when the input type=hidden.
Here's the form code:
[PHP]
<?php $action = $_REQUEST['action'];
$epic = $_REQUEST['epic']; ?>
<TR>
<TD>
<?php echo $action; ?>
<INPUT TYPE="HIDDEN" NAME="action" VALUE="
<?php
echo $action; ?>
"></TD>
<TD>
<?php
echo $epic; ?>
<INPUT TYPE="HIDDEN" NAME="epic" VALUE="
<?php
print $epic; ?>
" SIZE="4"></TD>
<TD><INPUT TYPE="TEXT" NAME="volume" SIZE="5"></TD>
<TD> </TD>
<TD> </TD>
</TR>
</TABLE>
<P><INPUT TYPE="SUBMIT" VALUE="Get Quote"</P>
</FORM>
[/PHP]
And the DB call:
<?php $getquote=@mysql_query("SELECT EPIC,SharePrice FROM SharePrices WHERE EPIC = '$epic'");
The variable $epic is passed through first time in the URL from another page and is then displayed in the form as text but stored as hidden data as i dont want the user the ability to change it. The data comes back fine if I remove the where clause from the select or plug in a value eg. EPIC=ABC or set $epic=ABC before the query. The problem however is the data contained in $epic after it is passed through. i have used echo to display it and it looks ok. i have used various string function to remove spaces etc but all to no avail. The field EPIC is defined as CHAR(4) on the MySQL table and is the primary key.
Anybody got any help?
Cheers.
11 11738
This question is being moved to the PHP forum.
ADMIN
My typical approach to situations like this is to set my MySQL query to a variable before I perform the query. That way I can see what, exactly my query is, and this allows me to copy and paste EXACTLY what is being sent via PHP.
Try this:
[PHP]
<?php
$qry = "SELECT EPIC,SharePrice FROM SharePrices WHERE EPIC = '$epic'";
echo $qry;
$getquote=@mysql_query($qry);
[/PHP]
The other thing that I should mention is that all error messages returned from your mysql_query() call are being suppressed, so you will not know if there is an error in your query. Remove the @ sign if you feel there may be an issue with the MySQL syntax.
I am new to PHP but have been using it for about a week. I'm having no trouble using html forms to recall data from a MySQL table when the input type=text but i cant seem to find a way of recalling the data from the MySQL table when the input type=hidden.
Here's the form code:
<?php $action = $_REQUEST['action'];
$epic = $_REQUEST['epic']; ?>
<TR>
<TD>
<?php echo $action; ?>
<INPUT TYPE="HIDDEN" NAME="action" VALUE="
<?php
echo $action; ?>
"></TD>
<TD>
<?php
echo $epic; ?>
<INPUT TYPE="HIDDEN" NAME="epic" VALUE="
<?php
print $epic; ?>
" SIZE="4"></TD>
<TD><INPUT TYPE="TEXT" NAME="volume" SIZE="5"></TD>
<TD> </TD>
<TD> </TD>
</TR>
</TABLE>
<P><INPUT TYPE="SUBMIT" VALUE="Get Quote"</P>
</FORM>
And the DB call:
<?php $getquote=@mysql_query("SELECT EPIC,SharePrice FROM SharePrices WHERE EPIC = '$epic'");
The variable $epic is passed through first time in the URL from another page and is then displayed in the form as text but stored as hidden data as i dont want the user the ability to change it. The data comes back fine if I remove the where clause from the select or plug in a value eg. EPIC=ABC or set $epic=ABC before the query. The problem however is the data contained in $epic after it is passed through. i have used echo to display it and it looks ok. i have used various string function to remove spaces etc but all to no avail. The field EPIC is defined as CHAR(4) on the MySQL table and is the primary key.
Anybody got any help?
Cheers.
Thanks for for the help. Took your advice and assigned my query to a variable first and also removed the @. Now i'm printing out th query I see that if assign a value to $epic before the query:
$epic=ABC;
I always get my data back and the query shows as:
SELECT EPIC,SharePrice FROM SharePrices WHERE EPIC = 'ABC'
However if i remove $epic=ABC; the query looks like:
SELECT EPIC,SharePrice FROM SharePrices WHERE EPIC = ' ABC '
with a space before and after the ABC. i tried TRIM($epic) but this made no difference. Any ideas?
echo substr($epic,4,3);
This shows the data as ABC. I havent added spaces in front of this as far as I am aware anywhere. TRIM doesnt seem to remove the spaces.
Check the source that it outputs. It looks like you should have a whole bunch of [undesired] newline characters in there.
There seems to be 4 blanks spaces in front of the variable $epic when its recalled from a url using REQUEST. However it has & to split up the variables. Is it just coinidence that this is 4 long. How can i strip out the blank spaces?
There seems to be 4 blanks spaces in front of the variable $epic when its recalled from a url using REQUEST. However it has & to split up the variables. Is it just coinidence that this is 4 long. How can i strip out the blank spaces?
[HTML]
<INPUT TYPE="HIDDEN" NAME="action" VALUE="
<?php
echo $action; ?>
"></TD>
[/HTML]
Should be:
[HTML]
<INPUT TYPE="HIDDEN" NAME="action" VALUE="<?php echo $action; ?>"></TD>
[/HTML]
etc.
Tabs and newlines in an input's value field count, just like they do in between <textarea> tags.
It works. Many Thanks pbmods.
It works. Many Thanks pbmods.
You are many welcome. But be careful; they spend really quickly!
pbmods for the win!
It works. Many Thanks pbmods.
how can i send input hidden data one page to another page and then send to database? can somebody help me?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Phillip T. Murphy |
last post by:
Well, after half pulling my hair out messing with this, I am thinking it is
not possible. I did research and found references to "sub-queries" not
possible in MySQL (I am using 4.0.18-32 with PHP...
|
by: garbagecatcher |
last post by:
Hello,
here's my problem:
On my web server I generate a file, I need to send this
file to a different web server.
I have no control over the other web server.
The only way they accept...
|
by: Walter |
last post by:
Hi,
The user has to type his name into input a input field (type = text).
This name must be passed to another ASP file.
I did this but nothing happened:
<form id=ins method="post"...
|
by: Jim Tome |
last post by:
Hi,
I am trying to change and pass the value of a hidden input type on a
form tag to a cgi processing script based on the value of a checkbox
within the form:
function CheckBoxes () {
if...
|
by: IamtheEvster |
last post by:
Hi All,
I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am
unable to call a MySQL stored procedure that returns output parameters
using mysql, mysqli, or PDO. I'm having a...
|
by: zwieback89 |
last post by:
Hi,
I have a org tree with hierarchical display of employees built using
classic asp and vbscript.
I also have list of radio buttons for report names.
I have 1 select box with dates in it....
|
by: brock797 |
last post by:
hey im just starting to learn php and mysql, i am using CentOS 5 and have all the neccisary programs compiled correctly (apache, php, mysql, etc) i can use mysql from the command line with no flaws,...
|
by: adamace5o |
last post by:
hi, i am trying to use a hidden form as a method of storing varibles for use throughout an online quiz site.
I am using mysql to hold data about the users ie user id username and user password...
|
by: Jack Gray |
last post by:
I have a form requiring data input for all fields. When any field is left blank and the data is submitted, the cgi file generates a new form which is populated with data already input and an error...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
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: 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: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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: 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: 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
| |