Jump to content

phpnerd

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.thescriptsdirectory.com

Profile Information

  • Gender
    Not Telling

phpnerd's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello; I know! But how can I get the same results in a proper way without having to loop the query? <?php function createDatesArray($days) { $output = array(); $month = date("m"); $day = date("d"); $year = date("Y"); for($i=1; $i<=$days; $i++) { $output[] = date('Y-m-d',mktime(0,0,0,$month,($day+$i),$year)); } return $output; } $dates = createDatesArray("365"); foreach($dates as $d) { echo $query = "INSERT INTO DATES (day) VALUES ('".$d."')"; echo $d."<br />"; } ?>
  2. Thanx all for the response. Unfortunately I didnt got any answer which is useful.
  3. Thanks for your response. I appreciate that.
  4. I am looking for a code to check whether an url opens with www or non www. For example http://www.example.com and http://example.com
  5. Hi All, I am looking for a script in php which can check whether an url is www or non www. I have searched extensively in google but nothing conclusive has appeared. It would be of great help if someone can throw light into this.
  6. Hi All, I would like to get domain age. I searched for code in google and I got the following code. class whois { const timeout = 30; const whoishost = 'whois.internic.net'; public static function lookup($domain){ $result = ""; $errno = 0; $errstr=''; $fd = fsockopen(whois::whoishost,43, $errno, $errstr, whois::timeout); if ($fd){ fputs($fd, $domain."\015\012"); while (!feof($fd)) { $result .= fgets($fd,128) . "<br />"; } fclose($fd); } return $result; } } $domain = 'google.com'; $result = whois::lookup($domain); if(strstr($result, " No match")){ echo $domain . " seems to be available"; }else{ echo $domain . " is in use"; echo "<hr>"; echo $result; } But this code returns a whole bunch of data all of which is not required. If it the output could be returned in an array, the desired result can be achieved. Can anyone suggest if there is any straight forward way to get individual data like the header response of a domain or may be the domain age. Any help would be appreciated.
  7. I want to use XML to dynamic generate a menu using jqtouch. But it does not work. My target is display same result as this static page <html> <head> <title>Cloth Store</title> <link type="text/css" rel="stylesheet" media="screen" href="jqtouch/jqtouch.css"> <link type="text/css" rel="stylesheet" media="screen" href="themes/jqt/theme.css"> <script type="text/javascript" src="jqtouch/jquery.1.3.2.min.js"></script> <script type="text/javascript" src="jqtouch/jqtouch.js"></script> <script type="text/javascript"> var jQT = new $.jQTouch(); </script> </head> <body> <div id="home"> <div class="toolbar"> <h1>Cloth Store</h1> </div> <ul class="edgetoedge"> <li class="arrow"><a href="#books">Books</a></li> <li class="arrow"><a href="#contactus">Contactus</a></li> </ul> </div> <div id="cloth"> <div class="toolbar"> <h1>Books</h1> <a class="button back" href="#">Back</a> </div> <p>We are a US-based organization providing a wide variety of books at a reasonable price</p> </div> <div id="contactus"> <div class="toolbar"> <h1>Contact Us</h1> <a class="button back" href="#">Back</a> </div> <p>XYZ Book Company</p> <p>11 Books Street, NY, NY 10012 </p> <p>USA</p> </div> </body> </html> I want to make the menu changed based on XML. therefore, i change the above one to 2 parts. HTML: <html> <head> <title>Cloth Store</title> <link type="text/css" rel="stylesheet" media="screen" href="jqtouch/jqtouch.css"> <link type="text/css" rel="stylesheet" media="screen" href="themes/jqt/theme.css"> <script type="text/javascript" src="jqtouch/jquery.1.3.2.min.js"></script> <script type="text/javascript" src="jqtouch/jqtouch.js"></script> <script type="text/javascript"> var jQT = new $.jQTouch(); var xhr =new XMLHttpRequest(); xhr.open("GET","text.xml",true); xhr.send(); var txt1=" <div class=\"toolbar\"><h1>CLC Plus</h1></div><ul class=\"edgetoedge\">"; var txt2=""; xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ xmlDoc=xhr.responseXML; x=xmlDoc.getElementsByTagName("name"); y=xmlDoc.getElementsByTagName("desc"); for (i=0;i<x.length;i++) { txt1=txt1 + "<li class=\"arrow\"><a href=\"#" + x.firstChild.nodeValue + "\">" + x.firstChild.nodeValue + "</a></li>"; txt2=txt2 + "<div id=\"" +x. firstChild.nodeValue + "</div><div class=\"toolbar\" align=right><h1>"+ x.firstChild.nodeValue+"</h1><a class=\"button back\" href=\"#\">Back</a></div><p>"+ y.firstChild.nodeValue+"</p>"; txt2 = txt2 + "</div>"; } txt1=txt1 + "</ul>"; document.getElementById('home').innerHTML = txt1; document.getElementById('content').innerHTML = txt2; } } </script> <body> <div id="home" class="current"> </div> <div id="content"> </div> </body> </html> XML: <?xml version="1.0" ?> <company> <name>Cloth</name><desc>We are a US-based organization providing a wide variety of books at a reasonable price</desc> <name>Contactus</name><desc><p>XYZ Book Company</p><p>11 Books Street, NY, NY 10012 </p><p>USA</p></desc> </company>
  8. I have installed a magento in my test server it was working fine. But when i moved to live server and tried to create a new category its showing a blank page or 500 error. Same thing happens in the front end. When a product is being added to cart. I have changed the base url.
  9. Step 1: Create a folder named images located in the path you are planning to place the php script you are about to create. Make sure it has write rights for everybody or the scripts won't work ( it won't be able to upload the files into the directory). Step 2: Paste the following code into a php file. Please read carefuly the comments. All steps are explained there. <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","100"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="images/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully! Try again!</h1>"; } ?> <!--next comes the form, you must set the enctype to "multipart/frm-data" and use an input type "file" --> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form>
  10. You can try jfileupload http://www.jfileupload.com/ They have many utility tools like jdisk explorer which will help you to achieve what you want.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.