Jump to content

$post problem, strip a word to only 3 characters....


wmguk

Recommended Posts

$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?

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 :(

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.