Archive for August, 2009

For anyone trying to use cURL to submit to an ASP/ASPX page that uses an image as the submit button. Make sure that you have ‘button_name.x’ and ‘button_name.y’ in the post fields. PHP names these fields ‘button_name_x’ and ‘button_name_y’, while ASP uses a dot. Also, as noted above, be sure to include the ‘__VIEWSTATE’ input field in your post request.

I assume that you nave a file named quote.txt, but you could make any other file which you want to convert to Image. Following is the code to enjoy creating Image from Text of your file. <?php Header ("Content-type: image/gif"); $textfile = "myquote.txt"; //Assume that you have myquote.txt $myquotes = array(); if(file_exists($textfile)){ $myquotes = file($textfile); srand ((float) microtime() * 10000000); $string = ‘-’.$myquotes[array_rand($myquotes)]; …

My old approach for Ajax

 on August 21, 2009

function createRequestObject(){ var request_o; //declare the variable to hold the object. var browser = navigator.appName; //find the browser name if(browser == "Microsoft Internet Explorer"){ /* Create the object using MSIE’s method */ request_o = new ActiveXObject("Microsoft.XMLHTTP"); }else{ /* Create the object using other browser’s method */ request_o = new XMLHttpRequest(); } return request_o; //return the object } //////////////////////////////////////////// var http = createRequestObject(); /* …

This is easily done with the reset function, like this : reset($array); Here is code: <?php $num = array("Item1","Item2","Item3"); next($num); $value = current($num); echo "We are $value\n"; $first = reset($num); echo "Back $first"; ?>

I needed a way to create a model and controller without actually having an associated table in the database. I particularly wanted to make use of the $validate array so I could easily validate my fields and keep the validation logic in the model. CakePHP will throw an error if you create a model for a table that doesn’t exist. Adding this to …

session_start(); require("includes/dbcon.php"); require("includes/config.php"); require("includes/common.php"); switch($_REQUEST['option']){ case "login": $msgFail=""; if (noSpecialChars($_REQUEST['username'])) { $query="SELECT username FROM member WHERE username=’".$_REQUEST['username']."’"; $rs = mysql_query($query); if(mysql_num_rows($rs)!=0) { echo "<span class=msgFail>User ID Already Exists. Please Choose Another.</span>"; } else if (strlen($_REQUEST['username'])<7){ echo "<span class=msgFail>User ID Length Must at Least 7 Characters.</span>"; } else { echo "<span class=msgSuccess>Available. You Can Proceed.</span>"; } } else { echo "<span class=msgFail>User ID must …

The following table describes the maximum length for each type of identifier. Database – 64 bytes Table – 64 bytes Column – 64 bytes Index – 64 bytes Alias – 255 bytes There are some restrictions on the characters that may appear in identifiers:

SELECT DATEDIFF(’2007-03-07′,’2005-01-01′);

We can use LOAD DATA INFILE file_name; syntax to load data from a text file. but we have to make sure that a) data is delimited b) columns and data matched correctly