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?

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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