August 24th, 2008
Colon in PHP is not just as ternary operator, but it applied as part of control structure for conditional structure such as if…elseif….endif, for..endfor, it became human readable instead of using brace open { and close brace }, here is the sample:
/* Correct Method: */
if($a > $b):
echo $a.” is greater than “.$b;
elseif($a == $b): // Note the combination of the words.
echo $a.” equals “.$b;
else:
echo $a.” is neither greater than or equal to “.$b;
endif;
Here is the control structure that can be use with colon :
CS | (ending) KEYWORD
—————–|—————–
if() | endif
for() | endfor
while() | endwhile
foreach() | endforeach
switch() | endswitch
Reference could be read also at , http://id2.php.net/elseif, or you can read at, http://www.desilva.biz/php/endif.html
Tags: control structure with colon, if elseif endif, if endif, if endif colon
Posted in MySQL, Tutorial, Uncategorized | No Comments »
August 3rd, 2008
I am delphi programmer, in Delphi i use Now() to get the current datetime, how about in PHP ?
In PHP getdate() will similar with Delphi Now() function, and in PHP we get the simple way to extract the year, day, and month. Let’s take a look a sample below:
<?php
$currentDate = getdate();
$dateRegistered = $currentDate[year].’-’.$currentDate[mon].’-’.$currentDate[mday];
$timeRegistered = $currentDate[hours].’:’.$currentDate[minutes];
echo(”date : “.$dateRegistered);
echo(”<br>time : “.$timeRegistered);
?>
the code at above will show in browser looks like,
date : 2008-8-3
time : 21:42
And from the PHP documentation the getdate() function will returning array contains ten element.
- [seconds] - seconds
- [minutes] - minutes
- [hours] - hours
- [mday] - day of the month
- [wday] - day of the week
- [year] - year
- [yday] - day of the year
- [weekday] - name of the weekday
- [month] - name of the month
Here is the array of returning variable structure, the number represent in these array only to illustrate the array.
Array
(
[seconds] => 30
[minutes] => 10
[hours] => 15
[mday] => 20
[wday] => 5
[mon] => 4
[year] => 2008
[yday] => 4
[weekday] => Tuesday
[month] => January
[0] => 1122110888
).
Another Way to Insert Date to MySql Date field through PHP should someting like this,
$year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day'];
$birthdate = date($year.”-”.$month.”-”.$day);
mysql_query( “INSERT INTO person( birthdate ) VALUES( ‘$birthdate’ ) ” );
And, finally to insert current date and time to MySQL should something like this,
mysql_query( “INSERT INTO person(date_signin,time_signin) VALUES( current_date,current_time ) ” );
If you want to set default timestamp at MySQL field, just use timestamp as default value when creating the table, here is the sample
create table person( timestamp timestamp default CURRENT_TIMESTAMP );
you can write CURRENT_TIMESTAMP as lowercase or uppercase when the table creation.
Tags: Insert DateTime, MySQL Date Time, MySQL Date Time Field, PHP Date Time
Posted in MySQL, PHP | 1 Comment »
August 3rd, 2008
JavaScript would be usefull to validate user entry to fill the form, because it validate in user browser. But becarefull when using JavaScript, one mistypo can make your JavaScript cannot run properly or JavaScript going nowhere. Here is the simple code to why JavaScript will going nowhere,
<script><!–
<br /–>
function checkForm()
{
var cemail, cpassword1, cpassword2,cfirstname, clastname;
with(window.document.regform)
{
cemail = email;
cpassword1 = user_password;
cpassword2 = confirm_password;
< code continue….>
Now let see the html form
<form id=”regform” method=”post”>
<table border=”0″ width=”800″>
<tbody>
<tr>
<td align=”right”>
<p class=”style1″>Email</p>
</td>
<td width=”459″><input id=”email” name=”email” type=”text” /></td>
</tr>
<tr>
<td class=”style1″ align=”right”><span class=”style4″>Password</span></td>
<td><input id=”password” name=”user_password” type=”text” /></td>
</tr>
<tr>
<td class=”style1″ align=”right”><span class=”style4″>Confirm Password</span></td>
<td><input id=”confirmpassword” name=”confirmpassword” type=”text” /></td>
</tr>
Have you notice which different name variable compare to variable in javascript?
Yes that’s true, in JavaScript there is line with code cpassword2 = confirm_password and in the form the code is <input id=”confirmpassword” name=”confirmpassword” type=”text” />
Those mistype can make JavaScript will not work, but in web browser the form will appear normal, in fact when user click submit form, the validation of JavaScript will not work or doesn’t make any effect. So becarefull with mistype.
Some IDE provide debugging and check syntax, so you can safe your time when developing your web with JavaScript.
Posted in Uncategorized | No Comments »
July 26th, 2008
IBM releasing free office which we could call it Lotus Symphony, despite debating which better OpenOffice or Free Lotus Shymphony we should proud that Lotus Symphony built base on Eclipse Framework. Eclipse framework is the open source framework which the power major IDE Framework such as JBuilder, Aptana, etc.
I just try and use it for a while until now, from my perspective, i love the idea using Eclipse to produce free office. Inside of Lotus Shymphony we can found spreadsheet like microsoft excel, document writer like microsoft document, presentation like microsoft powerpoint. The icon created as standard and great looking, the user interface also elegant, so we comfortable to use it. No wonder in February 12th 2008, Datamation Magazine chose Lotus Shymphony as Product of the year.
I think there are not people notice about Lotus Shymphony, since first release only a few website covering this Lotus Shymphony, but soon this good words will spread out, and people will more and more download and use Lotus Shymphony.
Here is the screenshoot of New Document,

What is the feature in side Lotus Shymphony ?
Short descriptions, i can found Save as feature which is compatible with Microsoft Office ( Word, Excel, Powerpoint ). And direct export to PDF, so we don’t need to install PDF printer anymore if we just want to print from Lotus Shymphony.
Where you can download Lotus Shymphony ?
Go here http://symphony.lotus.com
Tags: Eclipse Framework, Excel, Free Office, IBM, Power Point, Word
Posted in Review | No Comments »
July 26th, 2008
MySQL is the database that will differentiate between lowercase and uppercase fieldname, if you define the field name using lowercase then you should follow the lowercase field name in your programming code.
In PHP there are no error found if you access the fieldname using lowercase or uppercase, instead the result will not display or blank result. In order to describe this code in programming, i will create an example below,
create table webuser( ‘NAME’ varchar(100) );
Now access this table in your PHP,
$result = mysql_query(” select name from webuser”) or die(mysql_error());
echo “Name :”. $result['name'];
The result:
Name:
The code at above will not produce error in PHP even you put the die or error trap. This might be will be solve in next PHP version ( PHP6 or next version ). But for the PHP5 and below, you should be carefull using lowercase or uppercase, or putting mistype of fieldname using lowercase or uppercase.
Tags: Lowercase Field Name, MySQL, PHP, PHP Error Trap, Uppercase Field Name
Posted in MySQL, PHP | No Comments »
July 22nd, 2008
Everybody knows how MySQL wide spread across the web and domains. There are the tools that support the MySQL creation and management, from MySQL GUI tools until MySQL Workbench. MySQL Workbench is the successor of DBDesigner4 which design and wrote by Mike Zinner, the power and the force of DBDesigner4 increase in MySQL Workbench. I just curious what is inside of the MySQL Workbench, and DBDesigner4, to see the code is very simple and easy because this is an open source tools, you can download the source of DBDesigner4 from http://www.fabforce.net/dbdesigner4/, and also download the MySQL Workbench source code from http://dev.mysql.com/downloads/workbench/5.0.html. From the first time using the DBDesigner4, i just notice that the DBDesigner4 wrote using Delphi, that’s before i go to the DBDesigner4 website, after i go to the website, yes this is true using Delphi to develop. But for the current MySQL Workbench has been develop using C#. I don’t know the reason why Mike Zinner replace the code of MySQL Workbench from Delphi to C#. Can you tell me ?
Tags: C#, Database Design, Delphi, Mike Zinner, MySQL, MySQL Workbench
Posted in Uncategorized | No Comments »