Jump to content

Recommended Posts

Alright Using hidden fields I've been pushing this variable through a 5 page form, so when I use "UPDATE" i can run a WHERE = "id" to target the correct row to update,

$orderid

Well this is how I am declaring my VAR

[code=php:0]
else if($_POST['slow']){

//insert the values
$sql = "INSERT INTO joborder VALUES (NULL, '$usedbefore', '$nearestlocation', '$companyname', '$firstname', '$lastname', '$department', '$phone', '$fax', '$email', '$address', '$addresstwo', '$city', '$state', '$country', '$zip', '$positiontype', '$dressreq', '$dresscode',  '$positionclassification', '$positiontitle', '$employeesneeded', '$timeneeded', '$startdate', '$workinghours', '$workAddress', '$workaddresstwo', '$workcity', '$workstate', '$workzip', '$positiondescription', '$skillsrequired', '$educationrequired', '$additionalrequirements', '$checkedby', '$hourlyrate', SYSDATE(), '$reportto')";
mysql_query($sql) or die ( mysql_error() );

if(!$sql){
    echo 'There has been an error creating your order. Please contact the webmaster.';
} else {
$orderid = mysql_insert_id();
include '2rrf.html';
}
mysql_close();


?>
[/code]

then on the 2rrf.html page of have this field

[code]
<input name="orderid" id="<?php echo '$orderid' ?>" value="<?php echo '$orderid' ?>" size="25" checked />
[/code]

its literally posting "$orderid" instead of the var i want
Link to comment
https://forums.phpfreaks.com/topic/17985-setting-a-variable/
Share on other sites

It is literally posting $orderid because you're telling the script to. You must note that anything within single quotes ('here') will display exactly as it is. PHP will NOT format variables in it. If you want the value of $orderid to show, you must use double quotes ("here").

So this: <input name="orderid" id="<?php echo '$orderid' ?>" value="<?php echo '$orderid' ?>" size="25" checked />
becomes: <input name="orderid" id="<?php echo "$orderid" ?>" value="<?php echo "$orderid"?>" size="25" checked />

If you want an even shorter way to code this into your HTML, you can use [i]<?=$orderid?>[/i]. [i]<?=[/i] signifies that PHP should echo the variable after the equal sign. So, for example, you could use this:
<input name="orderid" id="<?=$orderid?>" value="<?=$orderid?>" size="25" checked />

Let me know if you do not understand or need any more help.
Link to comment
https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76970
Share on other sites

Also if Im echo'ing long strings and I have to put a variable somewhere I normaly use brackets... Like
echo "hello my name is corbin and I am {$age} years old";

That would work with out the brackets too, but I just hate going back and finding stupid errors later so I try to prevent them.
Link to comment
https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76972
Share on other sites

well now that the vars are going through I'm battling this other problem

I have a hidden field pushing "orderid" on the fallowing page

I think im calling WHERE wrong
[code=php:0]
$orderid = $_POST['orderid'];

$sql = "UPDATE joborder
SET positiontype = '$positiontype', dressreq = '$dressreq', dresscode = '$dresscode',  positionclassification = '$positionclassification', positiontitle = '$positiontitle', employeesneeded = '$employeesneeded', timeneeded = '$timeneeded', startdate = '$startdate', workinghours = '$workinghours', hourlyrate = '$hourlyrate'
WHERE orderid = '$orderid'";
mysql_query($sql) or die ( mysql_error() );
[/code]

its not updating my database, but i knows its connectiong and everything
Link to comment
https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76975
Share on other sites

echo out your query and run it in phpmyadmin - it will tell you if there is an error.  Alternatively the query will only 'work' if something is altered; if you try to update a record with the same data that is already there then affected rows will be 0
Link to comment
https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76983
Share on other sites

You may want to try this:

[code]$sql = "INSERT INTO joborder (positiontype,dressreq,dresscode,positionclassification,positiontitle,employeesneeded,timeneeded,startdate,workinghours,hourlyrate) values ('$positiontype', '$dressreq', '$dresscode', '$positionclassification', '$positiontitle', '$employeesneeded', '$timeneeded', $startdate', $workinghours', '$hourlyrate')";
mysql_query($sql) or die (mysql_error());[/code]
Link to comment
https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76996
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.