Re: [PHP-DB] String manipulation
You can do like this: $str = 'helloworld'; echo preg_replace('//', ' ', $str); this will print out -> h e l l o w o r l d Olavi Ivask > How would I put a space after each letter: > > echo str_shuffle(stripslashes(mysql_result($word_result,0,"word")); > > Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String manipulation
Ron Piggott wrote: How would I put a space after each letter: echo str_shuffle(stripslashes(mysql_result($word_result,0,"word")); Ron CSS best handles styling E.G. OR $word_result"; ?> Increase the em value to customize the spacing Louise -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String manipulation
How would I put a space after each letter: echo str_shuffle(stripslashes(mysql_result($word_result,0,"word")); Ron
Re: [PHP-DB] String comparision issue with change of databases
On Nov 23, 2007 5:42 PM, Stut <[EMAIL PROTECTED]> wrote: > Tamkhane, Pravin wrote: > > Hi All, > > I am trying to write a simple user verification(not using MD5 hash) . I > > have users table in database which contains login_id and passwd for > > registered users. I am using PDO for this purpose. If i use MySQL > > database, following code for user verification works well without any > > problem. But if change $dsn to use PostgreSQL database, code fails at > > if( $passwd === $records[0]['passwd']). After some experiementation, I > > realized that $passwd holds password string ( assume '1234' for time > > being) In case of MySQL $records[0]['passwd'] holds password string > > '1234' as expected and code works. But in case of PostgreSQL, > > $records[0]['passwd'] holds 1234 rather than '1234' and hence comparison > > fails. Since I am using same code to register users in both cases, I > > doubt there would be any issue there. > > You're using === which does a type *and* value comparison. I'm guessing > that the MySQL driver does the conversion to an integer, whereas the > PostgreSQL driver doesn't. Change it to == and it'll work just fine. Actually the real issue was, while creating table in PostgreSQL, I used character(n) type for login_id and passwd columns, which actually will padd spaces at the end of login_id and passwd string to fill it upto n. Changing datatype of these columns to character varying (n) solves the problem. Hope this saves time for someone. Thanks, Pravin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String comparision issue with change of databases
Tamkhane, Pravin wrote: Hi All, I am trying to write a simple user verification(not using MD5 hash) . I have users table in database which contains login_id and passwd for registered users. I am using PDO for this purpose. If i use MySQL database, following code for user verification works well without any problem. But if change $dsn to use PostgreSQL database, code fails at if( $passwd === $records[0]['passwd']). After some experiementation, I realized that $passwd holds password string ( assume '1234' for time being) In case of MySQL $records[0]['passwd'] holds password string '1234' as expected and code works. But in case of PostgreSQL, $records[0]['passwd'] holds 1234 rather than '1234' and hence comparison fails. Since I am using same code to register users in both cases, I doubt there would be any issue there. You're using === which does a type *and* value comparison. I'm guessing that the MySQL driver does the conversion to an integer, whereas the PostgreSQL driver doesn't. Change it to == and it'll work just fine. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String comparision issue with change of databases
Hi All, I am trying to write a simple user verification(not using MD5 hash) . I have users table in database which contains login_id and passwd for registered users. I am using PDO for this purpose. If i use MySQL database, following code for user verification works well without any problem. But if change $dsn to use PostgreSQL database, code fails at if( $passwd === $records[0]['passwd']). After some experiementation, I realized that $passwd holds password string ( assume '1234' for time being) In case of MySQL $records[0]['passwd'] holds password string '1234' as expected and code works. But in case of PostgreSQL, $records[0]['passwd'] holds 1234 rather than '1234' and hence comparison fails. Since I am using same code to register users in both cases, I doubt there would be any issue there. { $loginId = $_REQUEST['loginid']; $passwd = $_REQUEST['passwd']; $dsn = "mysql:host=$hostName;dbname=$dbName"; $query = "SELECT * FROM users WHERE login_id='$loginId';"; $dbh = new PDO($dsn, $userName, $passWd); $result = $dbh->query($query); $records = $result->fetchAll(PDO::FETCH_ASSOC); if(!count($records)) { echo 'User does not exist! Get Resgitered Now!!'; } else { if( $passwd === $records[0]['passwd']) { echo 'User '.$loginId.' logged in successfully!'; } else { echo 'Invalid Password! Try Again'; } } $dbh = null; } Any pointers please? Any hints? Thanks, Pravin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] String manipulation
Are you trying to achieve this in the db or for the application? It sounds like the application, in which case I would get the string from the db and then use substr to pull out the various elements. $first_name = substr($rows['name'],0,1); $last_name = substr($rows['name'],1); Bastien From: "Chris Payne" <[EMAIL PROTECTED]> To: Subject: [PHP-DB] String manipulation Date: Mon, 2 May 2005 00:48:58 -0400 Hi there everyone, I'm working with a mysql Db where I have a single string that I have to split into 2 strings, the first character is the first name and I have that split off into it's own variable, but what I need to know is what's the best method to read the string again BUT ignore the first letter as that is already copied into $firstname? So basically I have $firstname defined from the one string, but I have to define $lastname from the SAME string value as the one I used for $firstname, BUT ignoring the first letter but I'm not sure what the best method is to achieve this? Any help would be very appreciated. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String manipulation
Hi there everyone, I'm working with a mysql Db where I have a single string that I have to split into 2 strings, the first character is the first name and I have that split off into it's own variable, but what I need to know is what's the best method to read the string again BUT ignore the first letter as that is already copied into $firstname? So basically I have $firstname defined from the one string, but I have to define $lastname from the SAME string value as the one I used for $firstname, BUT ignoring the first letter but I'm not sure what the best method is to achieve this? Any help would be very appreciated. Chris
RE: [PHP-DB] String pictures in MySQL
examples of how to get them into the db (use a blob field) http://www.weberdev.com/get_example-4063.html and get the out http://www.weberdev.com/get_example-4062.html bastien From: Bunmi AKinmboni <[EMAIL PROTECTED]> To: php-db@lists.php.net Subject: [PHP-DB] String pictures in MySQL Date: Fri, 18 Mar 2005 05:32:05 +0100 I want to store picture in a MySQL field. What type do I call the field and any guide or link on the net to tell me how to store the picture? Bunmi from Lagos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String pictures in MySQL
I want to store picture in a MySQL field. What type do I call the field and any guide or link on the net to tell me how to store the picture? Bunmi from Lagos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String Parsing/Escaping
Jochem Maas wrote: hi Alexander, interesting question regarding 'safety' v. readability v. speed - I'm sure you'll get different views depending on who you ask. Here is my take: Thank you Jochem! :) I rate speed as the least important issue - you can alway use a faster machine, get some more RAM etc if you really need a quick speed fix. making the code faster is the last exercise I do in any given project, and I almost always choose readability/'safety' over speed I know what you mean and also agree generally, however I am nevertheless usually trying to have the code as optimised as possible. If I just knew better Assembler I would probably code all my webstuff in .asm files ;D. Seriously, I prefer to have code as compact, small, efficient and optimised as possible a personal thing I guess. This is a compromise - can't imagine why anyone would choose this one. Well, perhaps because it is a compromise ;). Its readability is much better than with string concatenation however its performance drop is still not that bad because its a native function. YEAH! indeed its the slowest. but its so much more readable and you know its alot more maintainable (you don't have to change the escaping, sprintf'ing strategy in 100 places.). Its safer too because there is no chance of forgetting to escape the sql args. That were also exactly my reasons why I fancied it. Imagine you have a highly dynamic page that does 50 queries (using the 3rd technique you proposed), I would guesstimate that refactoring the code to do 2-3 less queries per request would get just as much speed increase (if not more) than by refactoring the code to use the 1st technique on all 50 queries Thats probably correct. (granted you could refactor both but heh there are other things to do than code PHP 24/7 ;-) I know, I know ;) And if speed really is a big issue - you may need to look into writing part of you application logic as a PHP extension (i.e. in C which is way faster anyway you cut it.) Well, my worries now dont go that far :) Again, thanks very much for sharing your thoughts with me. Alexander -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String Parsing/Escaping
hi Alexander, interesting question regarding 'safety' v. readability v. speed - I'm sure you'll get different views depending on who you ask. Here is my take: Alexander Mueller wrote: Hi, below are three versions of an SQL call along with escaping the passed value. > $value=mysql_escape_string($_POST['value']); > mysql_query('SELECT * FROM table WHERE field="'.$value.'"'); + Fastest Code - Con: Bad Readability, Value needs to be escaped separately I rate speed as the least important issue - you can alway use a faster machine, get some more RAM etc if you really need a quick speed fix. making the code faster is the last exercise I do in any given project, and I almost always choose readability/'safety' over speed > $value=mysql_escape_string($_POST['value']); > mysql_query(sprintf('SELECT * FROM table WHERE field="%s"', $value)); + Good Readability - Value needs to be escaped separately This is a compromise - can't imagine why anyone would choose this one. It's not my choice, I'll just skip to number 3 :-) sql_sprintf() is a custom version of sprintf() which automatically escapes all passed parameters. > mysql_query(sql_sprintf('SELECT * FROM table WHERE field="%s"', $_POST['value'])); + Good Readability, Value does not need to be escaped separately - Slowest Code YEAH! indeed its the slowest. but its so much more readable and you know its alot more maintainable (you don't have to change the escaping, sprintf'ing strategy in 100 places.). Its safer too because there is no chance of forgetting to escape the sql args. I think the speed difference can be measured in milliseconds - are you really worried about that? if your app is that heavy that you are trying to shave off milliseconds to make it usuable then there are possibly bigger problems. Imagine you have a highly dynamic page that does 50 queries (using the 3rd technique you proposed), I would guesstimate that refactoring the code to do 2-3 less queries per request would get just as much speed increase (if not more) than by refactoring the code to use the 1st technique on all 50 queries (granted you could refactor both but heh there are other things to do than code PHP 24/7 ;-) in order of importance to me (I often have to maintain/update my code): 1. security 2. readability/maintainability 3. speed/performance basically the more abstract your code is, the slower it will be - because you are asking it to do more for you. to me the extra milliseconds wait on a request are worth it, anything to avoid debug/maintainance hell! And if speed really is a big issue - you may need to look into writing part of you application logic as a PHP extension (i.e. in C which is way faster anyway you cut it.) ... Thanks, Alexander PS: All this code is considered to run under magic_quotes_gpc OFF. as it should be ;-) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String Parsing/Escaping
Hi, below are three versions of an SQL call along with escaping the passed value. > $value=mysql_escape_string($_POST['value']); > mysql_query('SELECT * FROM table WHERE field="'.$value.'"'); + Fastest Code - Con: Bad Readability, Value needs to be escaped separately > $value=mysql_escape_string($_POST['value']); > mysql_query(sprintf('SELECT * FROM table WHERE field="%s"', $value)); + Good Readability - Value needs to be escaped separately sql_sprintf() is a custom version of sprintf() which automatically escapes all passed parameters. > mysql_query(sql_sprintf('SELECT * FROM table WHERE field="%s"', $_POST['value'])); + Good Readability, Value does not need to be escaped separately - Slowest Code Up until now I have only used the first version for all SQL work I did. Now however I am seeking for a better and more abstracted solution. I did some quick tests (only for the string parsing, without actual SQL queries) and noticed that the performance (as expected) continually degrades by moving from the top code down the list. While the third version is probably the most secure one due to the fact that sql_sprintf() always checks for escape sequences, it is also the slowest. Especially when the same value is used multiple times because then it is (unnecessarily) escaped again and again for each call, whereas the second version only escapes it once. THIS however is at the same time the big advantage of the third code, because the developer does not need to escape the data manually. Now my question is, what would be a good/the best compromise respectively are there any other solutions for this particular issue? Thanks, Alexander PS: All this code is considered to run under magic_quotes_gpc OFF. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String question
Chris Payne wrote: Hi there everyone, I am having to read a string with text in, but the way the DB is written in the same string you have the price, for example” this doesn't sound like a DB problem, sounds more like a regexp problem. (i.e. php-db is probably the wrong list) CASARON 4G 50lb Sacks in Ton Lots $88.00 How can I strip out the 88.00 (Baring in mind it could be any number) into it’s own string? http://nl2.php.net/manual/en/ref.pcre.php NB: note the difference between using single and double quotes when defining your regexp. e.g: $regexp = '/^.*\$[ \t]?([0-9]+\.[0-9]{2})$/s'; and: $regexp = "/^.*\$[ \t]?([0-9]+\.[0-9]{2})$/s"; ...are not the same. assuming that the price is at the end of the string you and is preceeded by a dollar sign (with or without a seperating space) could do: $myString = " CASARON 4G 50lb Sacks in Ton Lots $88.00 \r\n \t\r\n "; $matches = array(); $found = preg_match( '/^.*\$[ \t]?([0-9]+\.[0-9]{2})$/s', /* some commented out alternatives */ // '/^.*\$([0-9]+\.[0-9]{2})$/s', // '/^.*\$([0-9]+\.00)$/s', // '/^.*\$(88\.00)$/s', // '/.*\$(\d+\.\d+)/s', trim($myString), /* make life easier have a trim */ $matches /* passed by ref */ ); print_r("original string:\n--\n$myString"); print_r("\n\ntrimmed string:\n--\n".trim($myString)."\n\n"); print_r("found: $found\n matches array contents:\n\n"); print_r($matches); ?> Thank you. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.816 / Virus Database: 554 - Release Date: 12/14/2004 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String question
Hi there everyone, I am having to read a string with text in, but the way the DB is written in the same string you have the price, for example” CASARON 4G 50lb Sacks in Ton Lots $88.00 How can I strip out the 88.00 (Baring in mind it could be any number) into it’s own string? Thank you. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.816 / Virus Database: 554 - Release Date: 12/14/2004
RE: [PHP-DB] String handling
Yeah, I thought so seeing as I had done it like that previously, turns out it was something else that was causing the problem ":D Thanks anyhow ":D -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED] Sent: Thursday, September 30, 2004 5:43 PM To: 'Darryl'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] String handling If you use the value from a text box in a mathematical equation or comparison, PHP will automatically attempt to handle it as an integer or some other numeric type (e.g., float). So if you did something like: if($_POST["myvar"] < 1){ ... } PHP would handle $_POST["myvar"] as an integer automatically since it's being compared to another integer. Chapter 7: Type Juggling in the PHP manual sums this all up nicely. If you want to explicitly cast your variable as an integer, you can do either: settype($_POST["myvar"], "integer"); OR $intval = (int) $_POST["myvar"]; Either way, you're still going to want to do some data validation to make sure that the value in your text box is a number and not a text string before you convert it because you may get unexpected results if you try to convert a string to an integer depending on the contents of the string. The String Conversion section in the Strings chapter of the PHP documentation provides examples of how strings get converted to integers (and other types) by PHP. I am certainly no expert on type casting and have been stung by problems like this in the past. But check out the parts of the PHP documentation I cited and you should be able to figure out what needs to be done. HTH, Rich > -Original Message- > From: Darryl [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 30, 2004 10:42 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] String handling > > > Hay, > > > > Is there a way to make a string into an integer? > > I have a value coming from a textbox and I want to check if > the amount in it > is < 1. > > > > Thanks, > > Darryl > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] String handling
If you use the value from a text box in a mathematical equation or comparison, PHP will automatically attempt to handle it as an integer or some other numeric type (e.g., float). So if you did something like: if($_POST["myvar"] < 1){ ... } PHP would handle $_POST["myvar"] as an integer automatically since it's being compared to another integer. Chapter 7: Type Juggling in the PHP manual sums this all up nicely. If you want to explicitly cast your variable as an integer, you can do either: settype($_POST["myvar"], "integer"); OR $intval = (int) $_POST["myvar"]; Either way, you're still going to want to do some data validation to make sure that the value in your text box is a number and not a text string before you convert it because you may get unexpected results if you try to convert a string to an integer depending on the contents of the string. The String Conversion section in the Strings chapter of the PHP documentation provides examples of how strings get converted to integers (and other types) by PHP. I am certainly no expert on type casting and have been stung by problems like this in the past. But check out the parts of the PHP documentation I cited and you should be able to figure out what needs to be done. HTH, Rich > -Original Message- > From: Darryl [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 30, 2004 10:42 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] String handling > > > Hay, > > > > Is there a way to make a string into an integer? > > I have a value coming from a textbox and I want to check if > the amount in it > is < 1. > > > > Thanks, > > Darryl > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String handling
$string = '10001'; if((int)$string) > 1) { echo 'Yep it is'; } -- Joseph Crawford Jr. Codebowl Solutions [EMAIL PROTECTED] 802-558-5247 For a GMail account contact me OFF-LIST -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String handling
Hay, Is there a way to make a string into an integer? I have a value coming from a textbox and I want to check if the amount in it is < 1. Thanks, Darryl
[PHP-DB] string manipulation
Hello everyone, this is my first post, so please bare with me. I am very new to php and i am currently working on modifying existing php e-commerce site. so my question is as follow and its more of a general question but it involves a db so i thought i would ask here i have a mysql db, in one of the fields, there is a description of an item, along with a url all in one field. what i need to do is to extract the url string from the description field. is there some sort of parsing call i can evoke to extract the url? Beginning with the http and ending with the first white space? Martin _ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] string
Didn't even think of looking for a mysql function to accomplish this. Thanks. On Thu, 2002-10-31 at 20:52, Beau Lebens wrote: > you can do this as a part of your db query > > check the string functions available for your rdbms. > > mysql would use something like; > > SELECT SUBSTRING(monthname(blah), 0, 3) AS monthAbbrev FROM tablename > > from memory > > HTH > > beau > > // -Original Message- > // From: John Coder [mailto:jcoder@;insightbb.com] > // Sent: Friday, 1 November 2002 9:47 AM > // To: [EMAIL PROTECTED] > // Subject: [PHP-DB] string > // > // > // I want to list months found in db by the first three letters as in an > // abbrevaition of the months i.e.: > // Jan > // Feb > // Mar > // Apr > // and so forth > // I can get the names by monthname(blah) but am stuck on converting > // strings to first three letters I"ve been trying explode("",$blah) but > // that doesn't work. I'm at a loss here I can't find the correct string > // function for this. help would be greatly appreciated. > // > // John Coder > // > // > // > // > // -- > // PHP Database Mailing List (http://www.php.net/) > // To unsubscribe, visit: http://www.php.net/unsub.php > // > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] string
DATE_FORMAT(your_column,'%b') or SUBSTRING() ---John Holmes... > -Original Message- > From: John Coder [mailto:jcoder@;insightbb.com] > Sent: Thursday, October 31, 2002 8:47 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] string > > I want to list months found in db by the first three letters as in an > abbrevaition of the months i.e.: > Jan > Feb > Mar > Apr > and so forth > I can get the names by monthname(blah) but am stuck on converting > strings to first three letters I"ve been trying explode("",$blah) but > that doesn't work. I'm at a loss here I can't find the correct string > function for this. help would be greatly appreciated. > > John Coder > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] string
you can do this as a part of your db query check the string functions available for your rdbms. mysql would use something like; SELECT SUBSTRING(monthname(blah), 0, 3) AS monthAbbrev FROM tablename from memory HTH beau // -Original Message- // From: John Coder [mailto:jcoder@;insightbb.com] // Sent: Friday, 1 November 2002 9:47 AM // To: [EMAIL PROTECTED] // Subject: [PHP-DB] string // // // I want to list months found in db by the first three letters as in an // abbrevaition of the months i.e.: // Jan // Feb // Mar // Apr // and so forth // I can get the names by monthname(blah) but am stuck on converting // strings to first three letters I"ve been trying explode("",$blah) but // that doesn't work. I'm at a loss here I can't find the correct string // function for this. help would be greatly appreciated. // // John Coder // // // // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, visit: http://www.php.net/unsub.php // -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] string
I want to list months found in db by the first three letters as in an abbrevaition of the months i.e.: Jan Feb Mar Apr and so forth I can get the names by monthname(blah) but am stuck on converting strings to first three letters I"ve been trying explode("",$blah) but that doesn't work. I'm at a loss here I can't find the correct string function for this. help would be greatly appreciated. John Coder -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String extraction from blobs. Extracted string to be placed into field within another table.
What is the most effective method of extracting from a blob specified text to be placed into another table field. This email message and all attachments transmitted herewith are tradesecret and/or confidential information intended only for the viewing and use of addressee. If the reader of this message is not the intended recipient, you are hereby notified that any review, use, communication, dissemination, distribution or copying of this communication is prohibited. If you have received this communication is error, please notify the sender immediately by telephone or electronic mail, and delete this message and all copies and backups thereof. Thank you for your cooperation. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] string concatenattion
The line $str= buffer[$i]; Should probably read: $str .= buffer[$i]; Mark -Original Message- From: roslyn jose [mailto:[EMAIL PROTECTED]] Sent: 23 September 2002 11:39 To: [EMAIL PROTECTED] Subject: [PHP-DB] string concatenattion hi, i have an array of strings and would like to create a single string from the array but starting somewhere in the middle of the array index and not from the start, is there any function for me to do a string concatenation. ive gone thro the manula and didnt find any, but if u have any bright ideas how this can be achieved, pls help. roslyn this string only prints the last element in the buffer, and no concat is done. pls help - Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP-DB] string concatenattion
Hey, try $str = "str.buffer[$i]; since . does the concatenation. Best regards Claudia -Ursprungliche Nachricht- Von: roslyn jose [mailto:[EMAIL PROTECTED]] Gesendet: Montag, 23. September 2002 12:39 An: [EMAIL PROTECTED] Betreff: [PHP-DB] string concatenattion hi, i have an array of strings and would like to create a single string from the array but starting somewhere in the middle of the array index and not from the start, is there any function for me to do a string concatenation. ive gone thro the manula and didnt find any, but if u have any bright ideas how this can be achieved, pls help. roslyn this string only prints the last element in the buffer, and no concat is done. pls help - Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] string concatenattion
hi, i have an array of strings and would like to create a single string from the array but starting somewhere in the middle of the array index and not from the start, is there any function for me to do a string concatenation. ive gone thro the manula and didnt find any, but if u have any bright ideas how this can be achieved, pls help. roslyn this string only prints the last element in the buffer, and no concat is done. pls help - Do you Yahoo!? New DSL Internet Access from SBC & Yahoo!
Re: [PHP-DB] string
Hi, .: B i g D o g :. Thank you, indeed right after I post my question, I was able to use strpos and substr functions to solve my problem. But yours is even simpler with only one function, cheers. Thanks a lot. Sincerely Bo "Ray Hunter" <[EMAIL PROTECTED]> ??:01a901c23108$8a881a30$[EMAIL PROTECTED] > list( name, rest ) = explode( '@', $email ); > > name = everything before the @ > rest = everything after @ > > .: B i g D o g :. > > > > - Original Message - > From: "bo" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Sunday, July 21, 2002 4:42 PM > Subject: [PHP-DB] string > > > > Hi, > > > > for any email end with @companyemail.com > > such as [EMAIL PROTECTED] > > how do I strip only the portion(in this case:bo) before the common > > ending:@companyemail.com ? > > Thanks a bunch! > > > > PHP: the solution to the web problem > > Best Regards to PHP Community > > > > Bo > > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] string
list( name, rest ) = explode( '@', $email ); name = everything before the @ rest = everything after @ .: B i g D o g :. - Original Message - From: "bo" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, July 21, 2002 4:42 PM Subject: [PHP-DB] string > Hi, > > for any email end with @companyemail.com > such as [EMAIL PROTECTED] > how do I strip only the portion(in this case:bo) before the common > ending:@companyemail.com ? > Thanks a bunch! > > PHP: the solution to the web problem > Best Regards to PHP Community > > Bo > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] string
Hi, for any email end with @companyemail.com such as [EMAIL PROTECTED] how do I strip only the portion(in this case:bo) before the common ending:@companyemail.com ? Thanks a bunch! PHP: the solution to the web problem Best Regards to PHP Community Bo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String datetime to DateTime
Thanks for the help I'm fairly certain a fancy preg_replace could do it all at once... (if you sit down and write it some late night, please share...) I didn't use the exact functions you suggested, not sure what the difference is (yet). Here's what I ended up with, it could easily be turned into a function: Glenn // get date string from between square brackets if (preg_match('/\[.*\]/',$RawLine,$M)) { // parse date: [19/Jun/2002:00:13:13 -0600] $tm = substr($M[0],1,26); // remove brackets $tm = preg_replace('/\x2F|\x3A/',' ',$tm); // replace '/' and ':' with ' ' $MonthStrings = array('/Jan/','/Feb/','/Mar/','/Apr/','/May/','/Jun/', '/Jul/','/Aug/','/Sep/','/Oct/','/Nov/','/Dec/'); $MonthNumbers = array('01','02','03','04','05','06', '07','08','09','10','11','12'); $tm = preg_replace($MonthStrings,$MonthNumbers,$tm); // replace Month Strings with Month Numbers $a = sscanf($tm,"%d %s %d %d %d %d %s",&$day,&$mon,&$year,&$hour,&$min,&$sec,&$offset); $tm = $year.'-'.$mon.'-'.$day.' '.$hour.':'.$min.':'.$sec; // reorganize unix date time to mySql date time echo "DateTime: ".$tm.""; // produces=> DateTime: 2002-06-19 0:13:13 } <[EMAIL PROTECTED]> wrote in message 097901c2188f$a2628230$[EMAIL PROTECTED]">news:097901c2188f$a2628230$[EMAIL PROTECTED]... > Hmm...odd. I guess their %s (yes that was a typo) looks for a space > as a delimiter and not the specified next one. > > Easiest workarounds off the cuff... > 1) sscanf() to get the bulk of the data out, then regex out the %s string. > 2) eregi_replace() Jun with the numeric > 3) Dump it as numeric instead of a string month name > 4) eregi_replace() the /'s with spaces then sscanf() it. > > 'Luck > > -Mike > > - Original Message - > From: "Glenn Holden" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, June 20, 2002 8:48 AM > Subject: Re: [PHP-DB] String datetime to DateTime > > > > Thanks for the help, Mike. > > Trouble with sscanf... > > > > Incidentally I changed the $s in the format string to %s, I think that was a > > typo. :-) > > > > $str = "12/Jun/2002:01:02:26 -0600"; > > $newstr = sscanf($str,"%d/%s/%d:%d:%d:%d > > %s",$day,$mon,$year,$hour,$min,$sec,$offset); > > > > The trouble I'm having is with the first %s. It doesn't see the next > > delimiter so it puts the remaining text up to the next space into the $mon > > string. > > result: > > $day = 12 > > $mon = Jun/2002:01:02:26 > > other variables are empty > > > > Looking at php help online, there was a spanish user comment that seemed to > > be the same problem. And even though I can't read spanish, it looks like > > only a work around was suggested. > > > > I can work around this further but does anyone have a solution using sscanf? > > I'm not too clear on the acceptable syntax for the format string. Some > > comments intimate that I could use regular expressions withing there, but it > > doesn't seem to work either. > > > > Thanks in advance for any thoughts. > > Glenn > > > > > > > > > > <[EMAIL PROTECTED]> wrote in message > > news:046401c217fb$56310b00$[EMAIL PROTECTED]... > > > DateTime formats are closer to what you have. > > > strtotime() will give you an unsigned integer(ususally long/32bit) for the > > > number of seconds since the unix epoch. > > > > > > Automagically from what you have to mySQL DateTime...nope...not that I can > > think of or find. > > > If you have the Unix timestamp in ulong format, you can use date() to put > > it in the correct format. > > > > > > Obvious workaround... > > > > > > MySQL retrieves and displays DATETIME values in '-MM-DD HH:MM:SS' > > format. > > > The supported range is '1000-01-01 00:00:00' to '-12-31 23:59:59'. > > > > > > $str = "12/Jun/2002:01:02:26 -0600"; > > > $newstr = sscanf($str,"%d/%s/%d:%d:%d:%d > > $s",$day,$mon,$year,$hour,$min,$sec,$offset); > > > $newdatestr = > > > > > > I never noticed that it didn't store the GMT offset befor
Re: [PHP-DB] String datetime to DateTime
Hmm...odd. I guess their %s (yes that was a typo) looks for a space as a delimiter and not the specified next one. Easiest workarounds off the cuff... 1) sscanf() to get the bulk of the data out, then regex out the %s string. 2) eregi_replace() Jun with the numeric 3) Dump it as numeric instead of a string month name 4) eregi_replace() the /'s with spaces then sscanf() it. 'Luck -Mike - Original Message - From: "Glenn Holden" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 20, 2002 8:48 AM Subject: Re: [PHP-DB] String datetime to DateTime > Thanks for the help, Mike. > Trouble with sscanf... > > Incidentally I changed the $s in the format string to %s, I think that was a > typo. :-) > > $str = "12/Jun/2002:01:02:26 -0600"; > $newstr = sscanf($str,"%d/%s/%d:%d:%d:%d > %s",$day,$mon,$year,$hour,$min,$sec,$offset); > > The trouble I'm having is with the first %s. It doesn't see the next > delimiter so it puts the remaining text up to the next space into the $mon > string. > result: > $day = 12 > $mon = Jun/2002:01:02:26 > other variables are empty > > Looking at php help online, there was a spanish user comment that seemed to > be the same problem. And even though I can't read spanish, it looks like > only a work around was suggested. > > I can work around this further but does anyone have a solution using sscanf? > I'm not too clear on the acceptable syntax for the format string. Some > comments intimate that I could use regular expressions withing there, but it > doesn't seem to work either. > > Thanks in advance for any thoughts. > Glenn > > > > > <[EMAIL PROTECTED]> wrote in message > news:046401c217fb$56310b00$[EMAIL PROTECTED]... > > DateTime formats are closer to what you have. > > strtotime() will give you an unsigned integer(ususally long/32bit) for the > > number of seconds since the unix epoch. > > > > Automagically from what you have to mySQL DateTime...nope...not that I can > think of or find. > > If you have the Unix timestamp in ulong format, you can use date() to put > it in the correct format. > > > > Obvious workaround... > > > > MySQL retrieves and displays DATETIME values in '-MM-DD HH:MM:SS' > format. > > The supported range is '1000-01-01 00:00:00' to '-12-31 23:59:59'. > > > > $str = "12/Jun/2002:01:02:26 -0600"; > > $newstr = sscanf($str,"%d/%s/%d:%d:%d:%d > $s",$day,$mon,$year,$hour,$min,$sec,$offset); > > $newdatestr = > > > > I never noticed that it didn't store the GMT offset before. heh. > > > > 'Luck > > > > -Mike > > > > > > - Original Message - > > From: "Glenn Holden" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, June 19, 2002 3:58 PM > > Subject: [PHP-DB] String datetime to DateTime > > > > > > > Hello All! > > > > > > I have a unix time stamp in string format like this: > > > > > > 12/Jun/2002:01:02:26 -0600 > > > > > > I am trying to turn that back into a mySQL DateTime value. I've > > > experimented with strtotime with no luck. I'm not really sure if that's > > > what it's for. > > > > > > I can, of course, parse the string manually to build a datetime that > MySQL > > > will accept, but isn't there a function that handles this? > > > > > > How do -you- do this? > > > > > > Thanks! > > > -Glenn > > > > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] string
Sure- $test = "text1"; if(substr($test, -1) == 1){ print "do something"; } else{ print "didn't equal 1 "; At 08:00 AM 5/17/2002 -0400, Natividad Castro wrote: >Hi to all, >how can I evaluate a variable? >For example >$test = "test1"; >then I want to evaluate if $test contains 1 at the end. >Is there any way to evaluate that variable to see if the number 1 is at the >end? >Thanks >Nato > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] string
Hi to all, how can I evaluate a variable? For example $test = "test1"; then I want to evaluate if $test contains 1 at the end. Is there any way to evaluate that variable to see if the number 1 is at the end? Thanks Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] string compare function
by the way, what are you actually trying to do with the code? there may be a different way of doing it which isn't so confusing? -Original Message- From: tomhilton [mailto:[EMAIL PROTECTED]] Sent: 17 January 2002 15:20 To: [EMAIL PROTECTED] Subject: [PHP-DB] string compare function Hi, this is more of an earlier post regarding the strcmp function and my problems with it on my Win98 machine. This is the actual code I used for the strcmp function, $errors=0; if (empty($username)||empty($pword)||empty ($conf_pword)||empty($redirect)) { echo "Please hit your browser's back button and fill in all fields"; $errors++; } $comp=strcmp($conf_pword,$pword); echo $comp; The result ($comp) always comes back -1 when $pword is the 2nd variable, and +1 when $pword is the 1st variable. It doesn't matter what the input is into the variables from the form the data comes from. Is it comparing the actual literals of the variable names? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] string compare function
take it you've tried having exactly the same value for each to test if the return is 0? it shouldn't be comparing literals, but it looks like it could well be! try putting "" round the variables, and various things like that? -Original Message- From: tomhilton [mailto:[EMAIL PROTECTED]] Sent: 17 January 2002 15:20 To: [EMAIL PROTECTED] Subject: [PHP-DB] string compare function Hi, this is more of an earlier post regarding the strcmp function and my problems with it on my Win98 machine. This is the actual code I used for the strcmp function, $errors=0; if (empty($username)||empty($pword)||empty ($conf_pword)||empty($redirect)) { echo "Please hit your browser's back button and fill in all fields"; $errors++; } $comp=strcmp($conf_pword,$pword); echo $comp; The result ($comp) always comes back -1 when $pword is the 2nd variable, and +1 when $pword is the 1st variable. It doesn't matter what the input is into the variables from the form the data comes from. Is it comparing the actual literals of the variable names? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] string compare function
Hi, this is more of an earlier post regarding the strcmp function and my problems with it on my Win98 machine. This is the actual code I used for the strcmp function, $errors=0; if (empty($username)||empty($pword)||empty ($conf_pword)||empty($redirect)) { echo "Please hit your browser's back button and fill in all fields"; $errors++; } $comp=strcmp($conf_pword,$pword); echo $comp; The result ($comp) always comes back -1 when $pword is the 2nd variable, and +1 when $pword is the 1st variable. It doesn't matter what the input is into the variables from the form the data comes from. Is it comparing the actual literals of the variable names? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] string compare function
post the entire line of code, (and the surrounding couple of lines?? and we'll get more of an idea. -Original Message- From: tomhilton [mailto:[EMAIL PROTECTED]] Sent: 17 January 2002 14:56 To: [EMAIL PROTECTED] Subject: [PHP-DB] string compare function Hi, I'm having a problem with the stcmp() function. I have it comparing two string variables, $pword and $conf_pword, in a script. I know they both have values, but the result always compares to 1 when $pword is the first variable in the function, and -1 when $pword is the 2nd variable in the function, no matter what string values are in the variables. It seems like the function is comparing the literal name "$pword" and "$conf_pword", not their values. I am working on a Win98 machine, does anyone have any suggestions as to what I'm doing wrong? Any help would be greatly appreciated -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.314 / Virus Database: 175 - Release Date: 11/01/02 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] string compare function
Hi, I'm having a problem with the stcmp() function. I have it comparing two string variables, $pword and $conf_pword, in a script. I know they both have values, but the result always compares to 1 when $pword is the first variable in the function, and -1 when $pword is the 2nd variable in the function, no matter what string values are in the variables. It seems like the function is comparing the literal name "$pword" and "$conf_pword", not their values. I am working on a Win98 machine, does anyone have any suggestions as to what I'm doing wrong? Any help would be greatly appreciated -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] string problem
There's an option in php.ini: magic_quotes_gpc = On/Off; If on, any GET, POST, and Cookie data will come back with \ marks before ' and " marks. Guesing one server has it set to Off, and one set to On. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Fri, 14 Sep 2001, Rick Emery wrote: > Don't know why you're getting problem. However, you can use stripslashes() > to avoid the problem. > > -Original Message- > From: Bruno Franx [mailto:[EMAIL PROTECTED]] > Sent: Friday, September 14, 2001 10:04 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] string problem > > > scenario: Win.nt 4.0 pach6a Workstation, IE 5.5, Apache/1.3.20, php 4.0.6 > wath goes wrong: when I set a string variable containing by example : " > hello "jack" " > on my html page php convert it to " hello \"jack\" " and I get no > errors > on another machine with same configuration I get > " hello "jack" " without quoting > any Ideas? > TIA > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] string problem
Don't know why you're getting problem. However, you can use stripslashes() to avoid the problem. -Original Message- From: Bruno Franx [mailto:[EMAIL PROTECTED]] Sent: Friday, September 14, 2001 10:04 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] string problem scenario: Win.nt 4.0 pach6a Workstation, IE 5.5, Apache/1.3.20, php 4.0.6 wath goes wrong: when I set a string variable containing by example : " hello "jack" " on my html page php convert it to " hello \"jack\" " and I get no errors on another machine with same configuration I get " hello "jack" " without quoting any Ideas? TIA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] string problem
scenario: Win.nt 4.0 pach6a Workstation, IE 5.5, Apache/1.3.20, php 4.0.6 wath goes wrong: when I set a string variable containing by example : " hello "jack" " on my html page php convert it to " hello \"jack\" " and I get no errors on another machine with same configuration I get " hello "jack" " without quoting any Ideas? TIA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] String Connection
To anyone that may know... I would like to connect with connection string in odbc_connect Any help or ideas? Thank you in advance, Andrés García -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]