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? Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/ 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); Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/#findComment-493025 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 Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/#findComment-493027 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.. Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/#findComment-493029 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) Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/#findComment-493055 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) Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/#findComment-493061 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'); Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/#findComment-493069 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 Link to comment https://forums.phpfreaks.com/topic/96314-post-problem-strip-a-word-to-only-3-characters/#findComment-493093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.