Limit characters in a long text
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello all, Have a question: I would like to limit the amount of data viewed. I searched but did not find anything. Here is my code: $get_c = select * from $table ORDER BY news_id DESC LIMIT 5; $get_c_res = mysql_query($get_c) or die(mysql_error()); while ($c = mysql_fetch_array($get_c_res)) { $news_id = $c['news_id']; $news_posted = $c['news_posted']; $news_subject = $c['news_subject']; $NEWS_D = nl2br(stripslashes($c['news_desc'])); } I would like to limit $NEWS_D to say 100 characters. - -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFEIaDzfw3TK8jhZrsRAuZsAJ9S6QCvo6Pyru45qh1dzzANyD/OUgCgpuTG RqcZaNUSgSA4TvHRusMzn18= =P+Is -END PGP SIGNATURE- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Limit characters in a long text
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Adams wrote: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html I recommend LEFT( ). If you are looking to do it in PHP then this is the wrong email list. Good luck. Sorry about that I realized I picked the wrong mailing list after I sent it. Sorry again. - -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFEIfUIfw3TK8jhZrsRAgBJAKCu9eiZbHWAY2VSYfqrwuGuoT/9ewCgj5to U26Z/uD9hPZs9ukwREkMq64= =gi7p -END PGP SIGNATURE- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: data backup
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tue, 07 Mar 2006 19:54:02 -0500 Mathieu Bruneau [EMAIL PROTECTED] wrote: kalin mintchev a écrit : hi all... what's the best way to periodically back up mysql data? so that databases and tables can be still usable even after a mysql upgrade? thanks... mysqldump man mysqldump for the usage. I use this as a backup everyday. I wrote a bash script and I fire it off using cron everyday. - -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.1 (GNU/Linux) iD8DBQFEDk2ofw3TK8jhZrsRAuxNAKCz4VDHRoFb4xWX/9mYUPACZFtJEACff9vK EOW3UeOeHpn4U/66cfgNlXQ= =Q7Wv -END PGP SIGNATURE-
Re: file permission
On Tuesday 28 February 2006 22:55, unplug wrote: Hi, When I use a query SELECT * into outfile '/tmp/report.csv' fields terminated by ',' lines terminated by '\n' FROM table;, it will create a file with the following permission and owner. -rw-rw-rw- 1 mysql mysql 2489 Mar 1 11:30 report.csv How can I change the default permission or the ownership of the file? Rgds, unplug chown your_username:your_username report.cvs Of course change the your_username to the user you are logged in as. -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: file permission
On Tuesday 28 February 2006 23:41, Joshua Kugler wrote: You can't do that. The mysql server runs as user mysql, so it cannot create files owned by another user. If you run the mysql server as root (don't!), you might be able to do that, but I do not believe mysql has a facility for changing the owner of a file. You are better off running a script as the user you want to own the file and outputing the results via the script. j- k- I was just going to post something similar to that. Try something like this: #!/bin/bash Your query you want to run... chown user:user /path/to/report.cvs Then put this in your cron.daily or where ever you wish to run it or crontab 00 03 * * * /path/to/script I think I explained that right. :) -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Number Searches
On Fri, 2006-02-24 at 10:02 -0600, John Trammell wrote: On Wed, 2006-02-22 at 16:49 -0600, Ariel Sánchez Mora wrote: So far i've been able to store ip addresses as strings like you would type them in DOS, for ex, '192.168.0.1'. This serves me great since my application uses IP addresses as strings in all cases. I've done queries with the IP column , for example, select office_name from table_1 where ip='10.100.1.1'; and have never had any problems. However, if you plan on sorting based on this column, strings with periods do not behave correctly, and the answers to my previous question on this list do not apply; it makes a good aproximation, though. You might want to look into MySQL functions INET_ATON() and INET_NTOA(): http://dev.mysql.com/doc/refman/4.1/en/miscellaneous-functions.html WOW, thank you! learn something every day. This is why I love the IT field! :) Thanks again. -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) signature.asc Description: This is a digitally signed message part
Re: email to db
On Sat, 2006-02-25 at 10:49 +0800, Mark wrote: Can anyone tell me if it is possible to send an email from outlook to a DB so it updates a record. I have a php tipping script hosted with a mysql DB but would like users to email their tips instead of loggin on the site. Mark Wouldn't be easier using a PHP form, then send it to a database?? -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) signature.asc Description: This is a digitally signed message part
RE: Number Searches
On Thu, 2006-02-23 at 10:49 -0600, Ariel Sánchez Mora wrote: Probably the problem is in php, or, more probably, in how you store first and then look for the IP address in your query. You should try your query in the mysql console; varchars work almost with anything and I put this example where I look for an IP address with your table, and it finds it correctly. Hope this helps; if you can't find the problem, try little steps with select * from portal_forums_users where ip = '192.168.1.0'; To try and find where you have a problem. You can even try select * from portal_forums_users where ip like '%192.168.1.0%'; The % are wildcards, and that would take care of periods you inadvertenly added/erased. I really think this is not a MySQL problem. mysql describe portal_forums_users; +---+--+--+-+-++ | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-++ | user_id | bigint(255) | | PRI | NULL| auto_increment | | ip| varchar(200) | YES | | NULL|| | signup_date | varchar(30) | YES | | NULL|| | city | varchar(200) | YES | MUL | NULL|| | state | varchar(100) | YES | | NULL|| | email_address | varchar(200) | YES | | NULL|| | username | varchar(100) | YES | | NULL|| | password | varchar(100) | YES | | NULL|| | yim | text | YES | | NULL|| | aol | text | YES | | NULL|| | web_url | text | YES | | NULL|| | post_count| varchar(255) | YES | | NULL|| | info | text | YES | | NULL|| | sig | text | YES | | NULL|| | avatar| text | YES | | NULL|| | css_id| int(11) | YES | | NULL|| | mod_f | varchar(20) | YES | | NULL|| | admin | varchar(20) | YES | | NULL|| +---+--+--+-+-++ 18 rows in set (0.00 sec) mysql select * from portal_forums_users; +-+-+-+--+---+---+--+--+--+--+-+ | user_id | ip | signup_date | city | state | email_address | username | password | yim | aol | web_url | post_count +-+-+-+--+---+---+--+--+--+--+-+ | 1 | 192.168.1.0 | x | x| x | x | x | x| x | x| x | x | x| x| x | 0 | x | x | | 2 | 10.100.1.1 | y | y| y | y | y | y| y| y| y | y +-+-+-+--+---+---+--+--+--+--+-+ 2 rows in set (0.00 sec) mysql select * from portal_forums_users where ip = '192.168.1.0'; +-+-+-+--+---+---+--+--+--+--+-+ | user_id | ip | signup_date | city | state | email_address | username | password | yim | aol | web_url | post_count +-+-+-+--+---+---+--+--+--+--+-+ | 1 | 192.168.1.0 | x | x| x | x | x | x| x | x| x | x | x| x| x | 0 | x | x | +-+-+-+--+---+---+--+--+--+--+-+ 1 row in set (0.00 sec) -Mensaje original- De: CodeHeads [mailto:[EMAIL PROTECTED] Enviado el: miércoles, 22 de febrero de 2006 17:35 Para: Ariel Sánchez Mora CC: mysql@lists.mysql.com Asunto: RE: Number Searches On Wed, 2006-02-22 at 16:49 -0600, Ariel Sánchez Mora wrote: So far i've been able to store ip addresses as strings like you would type them in DOS, for ex, '192.168.0.1'. This serves me great since my application uses IP addresses as strings in all cases. I've done queries with the IP column , for example, select office_name from table_1 where ip='10.100.1.1'; and have never had any problems. However, if you plan on sorting based on this column, strings with periods do not behave correctly, and the answers to my previous question on this list do not apply; it makes a good aproximation
Re: Number Searches
On Thu, 2006-02-23 at 22:04 -0500, Mathieu Bruneau wrote: Ok I got 2 informations for you: 1) IPv4 address are actually 32 bit integer, easily store in 32 bits fast search etc etc etc (You can google for more on this storage format). Normally you could find a way to goes from the string 192.168.1.1 to the equivalent int. Look for ip2long() function in PHP for example! 2) FULLTEXT indexes are a special type of index in MySQL, their use on numeric field doesn't make sense. To be used on ip string they would require some tweaking as they normally don't remember word under 3 letters if i'm correct. And last but not least they aren't use with a like but with a match You could however use an typical index here, or even better an unique index to ensure the validation! Hope it helps you in you development! See for all information about fulltext index in the manual http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html Thanks for the reply :) Yes I was figured that was the problem but I wanted to make sure that was it. I did get it working like Ariel suggested. (where ip='192.168.1.1') That worked. I just did a separate search for the IP's. Thanks again for all your help. -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) signature.asc Description: This is a digitally signed message part
Re: Permissions
On Thu, 2006-02-23 at 21:46 -0600, Walter Johnson wrote: #chown mysql:mysql /var/mysql-data #chmod 770 /var/mysql-data Try this, assuming the files are in there for the database. $chown -R mysql:mysql /var/mysql-data/* $chmod -R 770 /var/mysql-data/* Hope that helps. -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) signature.asc Description: This is a digitally signed message part
Number Searches
Hello all, I have searched but cannot find what I am looking for. I have a full index index on a table and on of the fields is a number field (IP Address). Can MySQL search for numbers?? Thanks, Will -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Number Searches
On Wed, 2006-02-22 at 16:49 -0600, Ariel Sánchez Mora wrote: So far i've been able to store ip addresses as strings like you would type them in DOS, for ex, '192.168.0.1'. This serves me great since my application uses IP addresses as strings in all cases. I've done queries with the IP column , for example, select office_name from table_1 where ip='10.100.1.1'; and have never had any problems. However, if you plan on sorting based on this column, strings with periods do not behave correctly, and the answers to my previous question on this list do not apply; it makes a good aproximation, though. Hope this helps, but I must admit I am not sure if this answers your question. An example in the mysql console would be great for clearing up your objetive. Regards, Ariel OK, I think I did not explain things right the first time. :( I have a table like so: CREATE TABLE `portal_forums_users` ( `user_id` bigint(255) NOT NULL auto_increment, `ip` varchar(200) default NULL, `signup_date` varchar(30) default NULL, `city` varchar(200) default NULL, `state` varchar(100) default NULL, `email_address` varchar(200) default NULL, `username` varchar(100) default NULL, `password` varchar(100) default NULL, `yim` text, `aol` text, `web_url` text, `post_count` varchar(255) default NULL, `info` text, `sig` text, `avatar` text, `css_id` int(11) default NULL, `mod_f` varchar(20) default NULL, `admin` varchar(20) default NULL, PRIMARY KEY (`user_id`), FULLTEXT KEY `full_index` (`city`,`state`,`username`,`email_address`,`ip`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Notice the FULLTEXT; I have the ip listed to be indexed. Using a PHP script I have it will not grab the IP that I am searching for, even though it *is* in the database. The ip's are entered into the database as 192.168.1.10. When I search for a username it works great. Is it because of the . (periods) in the search string?? Hopefully I explained that right this time!! :) LOL -- Best regards, ~WILL~ Key: http://code-heads.com/keys/ch1.asc Key: http://code-heads.com/keys/ch2.asc Linux Commands: http://code-heads.com/commands Linux Registered User: 406084 (http://counter.li.org/) signature.asc Description: This is a digitally signed message part