I am stuck in an odd dilemma. I have a script that I am trying to modify for use in a CMS, unfortunately the CMS does not allow me to use a field name as a number, which the script uses. I have a field in the table named 'ID', which auto increments. I want to add 'ID_' at the beginning of each new entered ID field so I can work around the above problem. The script uses the ID # as a field name, so instead of name="15", it will be shown as name="id_15". I hope that makes sense. Is this possible in MySQL? If not, i'm thinking there has to be a way in the PHP code when posting the info, that it adds it somehow?
echo "ID_" . $field_id; Code (markup): I have implemented this, unfortunately the form i'm using is now trying to modify the "ID_15" record, which of course does not exist. Am I SOL, and have to redesign this program completely?
if($bought > 0){ array_push($ar, $iid . "=" . $bought); $query = "insert into purchaseHistory (iid, username, quantity, boughtDate) values (" . $iid . ", '" . $myusername . "', " . $bought . ", NOW())"; $rs = mysql_query($query) or die("Could not query2: " . mysql_error()); } } Code (markup): Here is some code - the $iid is the actual variable changed. Is there anyway in the code above to strip the "ID_" out of the $iid variable before posting, so the actual number is just inserted? I know it seems odd, but it is the only workaround I can think of.
Thanks SoKickIt. I found this solution to work after googling it. $iid = preg_replace('/[^0-9]/','',$iid); Code (markup): I know nothing about security w/PHP - is this just as good as the code you posted? Thanks again for everything!