wmguk Posted March 15, 2008 Share Posted March 15, 2008 $general_order_query="INSERT INTO orders (loginid, orderdate, albumname, name_first, name_last, email, address1, address2, city, state, zip, country, phone, comments, ship_name, ship_address1, ship_address2, ship_city, ship_state, ship_zip, ship_country, ship_phone, ordered_items,total_quantity,total) VALUES('$login', '$orderdate', '".mysql_real_escape_string($_POST[albumname])."', '".mysql_real_escape_string($_POST[name_first])."', '".mysql_real_escape_string($_POST[name_last])."', '".mysql_real_escape_string($_POST[email])."', '".mysql_real_escape_string($_POST[address1])."', '".mysql_real_escape_string($_POST[address2])."', '".mysql_real_escape_string($_POST[city])."', '".mysql_real_escape_string($_POST[state])."', '".mysql_real_escape_string($_POST[zip])."', '".mysql_real_escape_string($_POST[country])."', '".mysql_real_escape_string($_POST[phone])."', '".mysql_real_escape_string($_POST[comments])."', '".mysql_real_escape_string($_POST[ship_name])."', '".mysql_real_escape_string($_POST[ship_address1])."', '".mysql_real_escape_string($_POST[ship_address2])."', '".mysql_real_escape_string($_POST[ship_city])."', '".mysql_real_escape_string($_POST[ship_state])."', '".mysql_real_escape_string($_POST[ship_zip])."', '".mysql_real_escape_string($_POST[ship_country])."', '".mysql_real_escape_string($_POST[ship_phone])."', //'".mysql_real_escape_string($_POST[albumname])."', '".$total_quantity."', '".$total."')"; Im trying to add to it so it says Prints - albumname where i have the // also need to create a totally new variable, called order_ref, which needs to be $login then 3 letters from $name_last and then a timestamp (22:20:33) how can i strip the name_last to just 3 letters? Quote Link to comment Share on other sites More sharing options...
dotBz Posted March 15, 2008 Share Posted March 15, 2008 hmm. how about trying: sprintf("%.3s", $name_last); Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 15, 2008 Author Share Posted March 15, 2008 hmm. how about trying: sprintf("%.3s", $name_last); sorry if that sounded daft, i was trying trim im fairly new to this game, so to get 3 digits from ".mysql_real_escape_string($_POST[name_last])." can i just sprintf("%.3s", ".mysql_real_escape_string($_POST[name_last])."); The problem is, someone made me this code, and i am really struggling to work it out Quote Link to comment Share on other sites More sharing options...
dotBz Posted March 15, 2008 Share Posted March 15, 2008 remove the quote and dot to add the other variables, you could do this: $var = sprintf("%s%.3s%s%s", $login, mysql_real_escape_string($_POST['name_last']), $timestamp); not sure.. Quote Link to comment Share on other sites More sharing options...
MAGiK602 Posted March 15, 2008 Share Posted March 15, 2008 Or when creating the database you could have made the field something like: name_last varchar(3) Quote Link to comment Share on other sites More sharing options...
Nhoj Posted March 15, 2008 Share Posted March 15, 2008 hmm. how about trying: sprintf("%.3s", $name_last); sorry if that sounded daft, i was trying trim im fairly new to this game, so to get 3 digits from ".mysql_real_escape_string($_POST[name_last])." can i just sprintf("%.3s", ".mysql_real_escape_string($_POST[name_last])."); The problem is, someone made me this code, and i am really struggling to work it out Could just do: mb_strcut(mysql_real_escape_string($_POST[name_last]), 0, 3); (http://us.php.net/manual/en/function.mb-strcut.php) Quote Link to comment Share on other sites More sharing options...
discomatt Posted March 15, 2008 Share Posted March 15, 2008 Or just $order_ref = $login . substr($name_last, 0, 3) . date('H:i:s'); Quote Link to comment Share on other sites More sharing options...
wmguk Posted March 15, 2008 Author Share Posted March 15, 2008 cheers guys, this is solved!! dunno why i kept getting errors with the simple $post, had a coffee and it works now thanks for the help Quote Link to comment 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.