anthonydamasco Posted August 18, 2006 Share Posted August 18, 2006 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,$orderidWell 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 Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/ Share on other sites More sharing options...
ToonMariner Posted August 18, 2006 Share Posted August 18, 2006 remove the single quotes Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76968 Share on other sites More sharing options...
corbin Posted August 18, 2006 Share Posted August 18, 2006 try[code=php:0]<input name="orderid" id="<?php echo $orderid; ?>" value="<?php echo $orderid; ?>" size="25" checked />[/code] Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76969 Share on other sites More sharing options...
Woolf Posted August 18, 2006 Share Posted August 18, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76970 Share on other sites More sharing options...
anthonydamasco Posted August 18, 2006 Author Share Posted August 18, 2006 thanks fixed it! huray! ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76971 Share on other sites More sharing options...
corbin Posted August 18, 2006 Share Posted August 18, 2006 Also if Im echo'ing long strings and I have to put a variable somewhere I normaly use brackets... Likeecho "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. Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76972 Share on other sites More sharing options...
anthonydamasco Posted August 18, 2006 Author Share Posted August 18, 2006 well now that the vars are going through I'm battling this other problemI have a hidden field pushing "orderid" on the fallowing pageI 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 Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76975 Share on other sites More sharing options...
ToonMariner Posted August 18, 2006 Share Posted August 18, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76983 Share on other sites More sharing options...
corbin Posted August 18, 2006 Share Posted August 18, 2006 Does the query die or does it just not do anything? Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76984 Share on other sites More sharing options...
Woolf Posted August 18, 2006 Share Posted August 18, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/17985-setting-a-variable/#findComment-76996 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.