RE: [PHP] searching multiple fields
Yes, hope you are using the MyISAM, full-text index is much better than 'LIKE'. If you use the way like 'name like '$name%' or org like '$name'', it will cost lots of your time... Best regards, Shiqi Yang -Original Message- From: Amir Mohammad Saied [mailto:[EMAIL PROTECTED] Sent: Friday, July 15, 2005 1:51 AM To: php-general@lists.php.net Subject: Re: [PHP] searching multiple fields Brent Baisley wrote: Sounds like you want to use full text indexing. Create one full text index spanning name, area, organisation. Then search on all three fields at once. SELECT * FROM sheet1 MATCH(name,area,organisation) AGAINST ('textstring* otherstring* etc*). The * means use LIKE searching. There are a bunch of other options you can use and also limitations. Read the manual for all the details. On Jul 14, 2005, at 4:37 AM, Ross wrote: Just to remember! this method works just with MyISAM table types. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] cannot connect to MySQL server and not sure why
Make sure that your ip is granted too. Best regards, Shiqi Yang -Original Message- From: Bruce Gilbert [mailto:[EMAIL PROTECTED] Sent: Thursday, July 14, 2005 11:27 PM To: php-general@lists.php.net Subject: [PHP] cannot connect to MySQL server and not sure why I am having trouble connecting to MySQL server through a PHP script and I am not sure why. the error I receive is: Warning: mysql_pconnect(): Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) in /hsphere/local/home/bruceg/inspired-evolution.com/search/include/connect.php on line 6 Cannot connect to database, check if username, password and host are correct. trying to connect with the following script: ?php $database=bruceg_search; $mysql_user = bruceg_webmaster; $mysql_password = password; $mysql_host = server-10.existhost.com; mysql_pconnect ($mysql_host, $mysql_user, $mysql_password); if (!$success) die (bCannot connect to database, check if username, password and host are correct./b); $success = mysql_select_db ($database); if (!$success) { print bCannot choose database, check if database name is correct.; die(); } ? I double checked the database and I have created a database called bruceg_search and added a user called bruceg_webmaster with all of the editing privileges. Of course 'password' is changes with the password used to connect in the actual script. and I double checked that to be correct as well. Any suggestions? -- ::Bruce:: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Echo array string index?
Yeah, you can use foreach. But *may be* you just find sth called array_keys(). Best regards, Shiqi Yang -Original Message- From: Joe Harman [mailto:[EMAIL PROTECTED] Sent: Thursday, July 14, 2005 4:45 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: Echo array string index? Hey Matt, you can print out the contents of your array by using print_r($arr) but more useful is using this foreach ($arr as $key = $value) { echo Key : .$key. Value : .$value; } Adios Joe On 7/13/05, Adam Hubscher [EMAIL PROTECTED] wrote: Matt Darby wrote: I have an array setup as such: *$arr['generated text']='generated number';* What would be the best way to echo the key in a loop? Seems pretty easy but I've never attempted... Thanks all! Matt Darby I'm not sure I understand the question. You could do foreach($arr as $key = $value) { print($key); }. There are also a number of functions that get the current key on the array's pointer: http://us2.php.net/manual/en/function.key.php http://us2.php.net/manual/en/function.array-keys.php But once again, it really comes down to what exactly it is you want to do... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Joe Harman - Do not go where the path may lead, go instead where there is no path and leave a trail. - Ralph Waldo Emerson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Arrays
I guess your purpose is to just save the row data from the mysql to the array each unit. So may be the result that you expected is sth like: $product[0] = 1; $product[1] = 2; $product[2] = 3; .. If you just loop for each new value in the loop and to destroy the array, you second example is okey. Best regards, Shiqi Yang -Original Message- From: Justin Gruenberg [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 12, 2005 7:43 PM To: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] Arrays On 12/07/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, How can i destroy an array? I mean i have a loop and for each new value in the loop i want to destroy the array. Something like that: while($row = mysql_fetch_array($result)) { $product[] = $product_id; // some code here } I've tried this but doesn't work while($row = mysql_fetch_array($result)) { $product = array(); $product[] = $product_id; // some code here } To destroy an array? First of all, where does $product_id come from? You gave us no code that gives us that. Second, if you're trying to make an array populated with a feild from each row returned, your first example will work, but not the second. The second example will empty the array, and start a new one (which doesn't make sense to me why you would do that--because in the end, you're only going to have the array with the last row returned). But if you're trying to destroy an array doing either: unset($an_array) or $an_array = array(); will do the job. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] back slashes
Yeah, mysql_escape_string() will help you. Best regards, Shiqi Yang -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Monday, July 11, 2005 9:42 AM To: Daniel Baughman Cc: php-general@lists.php.net Subject: RE: [PHP] back slashes On Fri, July 8, 2005 12:48 pm, Jay Blanchard said: [snip] Lets say I have a string: c:\www\test I want to insert it into a database, but what ends up getting inserted is: PHP3 and earlier: http://php.net/addslashes PHP4 (?) and later: http://php.net/myqsl_escape_string c:wwwtest I can not get php to double the back slashes no matter what I do! $string = str_replace(\\, , $string); This should have worked, for \, but there are other characters to worry about... So you must have made a typo or something when you tried this. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] how to get time cost for MySQL query
Yes, mysql will cache your same query every time. So what you need is to just test the microtime before and after your query script. If you just want to know how about the efficiency about your sql script, you can use the mysql_command line and explain it. Otherwise, I think trying to catch the query time by mysql in php script is useless as there are many other factors can affect you. Best regards, Shiqi Yang -Original Message- From: Ahmed Saad [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 12, 2005 11:43 PM To: php-general@lists.php.net Subject: [PHP] how to get time cost for MySQL query On 7/11/05, x [EMAIL PROTECTED] wrote: Since we can see the time cost each time we query MySQL through MySQL console (such as 75 rows in set (0.01 sec)), so I am wondering there is already an existing function which will return the value... I think you are confusing two things: mysql server and mysql command-line client. The time cost is calculated at the client side in mysql command-line client. It's not retrieved from the server but rather calculated with the help of three functions defined in mysql.cc: start_timer, end_timer, mysql_end_time (all are internal functions that don't have anything to do with the server). It's done more or less the way you would normally do it in php: (1) take down current time (2) do the query (3) take down time again and calculate the difference. -ahmed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to read PHP variables.
Firstly, I don't know why you want to change your configuration in real time? Then if you just keep your configuration in an array, then when you want to change and use it in your script, you can just $vars['varname'] = sth else. So pls give us more detail. Best regards, Shiqi Yang -Original Message- From: Bruno B B Magalhães [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 12, 2005 8:21 PM To: php-general@lists.php.net Subject: [PHP] How to read PHP variables. Hi you all! That's my problem: I have a configuration files with the following structure... $vars['varname'] = 'varvalue'; And I would like to have a module to change those parameters, but I don't know how to write a pattern to match it... Thanks in advance... Best Regards, Bruno B B Magalhaes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Number of users
The current users' num is actually not exactly and it's just an estimated one. You can save your users' data in an array, and every time receive a request from a browser you should modify your array and then you can get how many users are online. And also there need another function to clean up the expired users. Best regards, Shiqi Yang -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 12, 2005 4:26 PM To: php-general@lists.php.net Subject: [PHP] Number of users Hello all, I have some questions and I hope someone could answer them 1. Is there a way to find out how many users currently browsing pages at my web site? 2. If I write down the IP of a user that log on my web site, can I check later if the IP still browsing pages at my web site or if he had left my website? Thanks yaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Plz, help
You can use select u.a as u.a, v.a as v.a .. Best regards, Shiqi Yang -Original Message- From: adolfas [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 12, 2005 2:42 PM To: php-general@lists.php.net Subject: [PHP] Plz, help Hi, I have a line: $sql=select u.*, p.name_lt as pareiga from nese_users u left join nese_pareigos p on p.id=u.pareiga order by data desc; As I understand there are 2 tables: nese_users and nese_pareigos I need to know what atributes belong to what table form that line. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] alternative to empty
May be you can try (string)$string or (int)$string (seemed a little strange). Any way Ross, we need to see ur code to determine your problem. Best regards, Shiqi Yang -Original Message- From: Philip Hallstrom [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 12:15 AM To: Dan Rossi Cc: Ross; php-general@lists.php.net Subject: Re: [PHP] alternative to empty I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. If ($string == '') ?? Careful... notice the differenec b/n == and === ?php $s = 0; if ($s == '') { print(==\n); } if ($s === '') { print(===\n); } ? % php foo.php == % -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] foreach in php4
Try this: function mul($value){ $value = $value * 2; } $arr = array(a = 1, b = 2, c = 3, d = 4); array_walk($arr, 'mul'); var_dump($arr); Best regards, Shiqi Yang -Original Message- From: Dotan Cohen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 05, 2005 1:40 PM To: PHP Lists Subject: [PHP] foreach in php4 I am on php 4.x. I see that in php5 I can do this (not the before $value): $arr = array(1, 2, 3, 4); foreach ($arr as $value) { $value = $value * 2; } // $arr is now array(2, 4, 6, 8) In order to create the same effect, I have been doing this: $pre_arr = array(1, 2, 3, 4); $arr = array(); foreach ($pre_arr as $value) { $arr[] = $value * 2; } // $arr is now array(2, 4, 6, 8) Is there a better way? Thanks. Dotan Cohen http://lyricslist.com/lyrics/artist_albums/327/martin_ricky.php Martin, Ricky Song Lyrics -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php