Posts Tagged ‘mysql’

PHP convert date to timestamp

April 21st, 2009

Instead of finding a way to manipulate 2 date pickers and find the range of dates and use each date.

why not convert each date produced by the date picker into unix timestamp and find the range

<?

//begindate/enddate has a format of  “m d Y”

$splitbegindate = explode(‘ ‘, $begindate);
$splitenddate = explode(‘ ‘, $enddate);
$timestamp = mktime(’00′, ’00′, ’00′, $splitbegindate[0], $splitbegindate[1], $splitbegindate[2]);
$timestampend = mktime(’23′, ’59′, ’59′, $splitenddate[0], $splitenddate[1], $splitenddate[2]);

// and then do the query
$query = “Select count(*),username, SUM(time_duration),… from $table where timestamp BETWEEN $timestamp AND $timestampend group by …. “;

?>

much easier right?

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Import and Export Mysql Database

April 16th, 2009

Found this pretty useful

For exporting DB:

mysqldump -u username -ppassword database_name > FILE.sql

while importing DB:

mysql -u username -ppassword database_name < FILE.sql

 easy but useful.. =) oh.. and got it on this site: Clockwatchers thanks. =)

Finally seeing the light.. =)

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Updates: freeTTS with emotions, perl scripting

April 9th, 2009

Nearly Done with what i want for my FYP CA2. Its more of the top layer being uncovered and many more layers to go. But i did add a few features and im pretty pleased with my result. Shall post an applet once im done.

Implementing machine learning? Possible using weighted phrases and sentences? Still puzzling but I do believe i’ll get it soon enough..

On the other hand, i was implementing a perl script to parse a log file into mysql database. So far seems pretty easy, left with implementing the correct data type for some of the variables.  

Busy busy busy. and im still puzzled with ms robotics studio.

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Unable to connect to the database:The MySQL adapter “mysql” is not available.

April 3rd, 2009

was trying to use PHP, mysql, IIS and joomla.

somehow, i keep getting this error

Unable to connect to the database:The MySQL adapter “mysql” is not available.

well. most forum says its my php not having the extension and php.ini not having the extension as follows:

extension=php_mysql.dll

I install and uninstall countless times, removed the ini in the process too to make sure things are properly installed. and i check my php.ini and the extension is there.. the dll file is there too.

I dunt understand whats wrong.. zzz. maybe its the lack of sleep…

on the sidenote.. im trying out symfony. hopefully it’ll be good. =) and learning cron jobs and some bash scripts.. =)

VN:F [1.9.6_1107]
Rating: 6.8/10 (4 votes cast)
VN:F [1.9.6_1107]
Rating: -1 (from 3 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Importing CSV to mysql

March 17th, 2009

Something pretty straight forward..

if i have a csv as shown below

to import to mysql
1) go to the directory of the csv file. e.g. words.csv

“airy”
“amused”
“animated”
“beatific”
“blissful”
“blithe”
“bright”
“brisk”
“buoyant”
“cheerful”

3) go into mysql admin

mysql -u root -p

4) run command

>LOAD DATA INFILE “./words.csv” INTO TABLE happy FIELDS TERMINATED BY “,” OPTIONALLY ENCLOSED BY “”"” TERMINATED BY ‘\n’;

the words.csv is saved under /var/lib/mysql.

5) and its done.

mysql> select * from happy;

+—————-+
| name            |
+—————-+
| airy                |
| amused        |
| animated      |
| beatific          |
| blissful           |
| blithe             |
| bright            |

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare
Get Adobe Flash playerPlugin by wpburn.com wordpress themes