Jump to content

chintansshah

Members
  • Posts

    244
  • Joined

  • Last visited

Everything posted by chintansshah

  1. use below as an query $selectObjects = "SELECT * FROM `objecten` ORDER BY ".$item['objectName']." ";
  2. Mysql is faster then PHP, Because, during the query excution you can check and validate in query itself. your execution time gets reduced.
  3. I feel that, there are permission issues. You can install php, mysql and Apache Please follow th steps. Install Apache To start off we will install Apache. 1. Open up the Terminal (Applications > Accessories > Terminal). 2. Copy/Paste the following line of code into Terminal and then press enter: sudo apt-get install apache2 3. The Terminal will then ask you for you're password, type it and then press enter. Testing Apache To make sure everything installed correctly we will now test Apache to ensure it is working properly. 1. Open up any web browser and then enter the following into the web address: http://localhost/ You should see a folder entitled apache2-default/. Open it and you will see a message saying "It works!" , congrats to you! Install PHP In this part we will install PHP 5. Step 1. Again open up the Terminal (Applications > Accessories > Terminal). Step 2. Copy/Paste the following line into Terminal and press enter: sudo apt-get install php5 libapache2-mod-php5 Step 3. In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this: sudo /etc/init.d/apache2 restart Test PHP To ensure there are no issues with PHP let's give it a quick test run. Step 1. In the terminal copy/paste the following line: sudo gedit /var/www/testphp.php This will open up a file called phptest.php. Step 2. Copy/Paste this line into the phptest file: <?php phpinfo(); ?> Step 3. Save and close the file. Step 4. Now open you're web browser and type the following into the web address: http://localhost/testphp.php The page should look like this: Test PHP Page Congrats you have now installed both Apache and PHP! Install MySQL To finish this guide up we will install MySQL. (Note - Out of Apache and PHP, MySQL is the most difficult to set up. I will provide some great resources for anyone having trouble at the end of this guide.) Step 1. Once again open up the amazing Terminal and then copy/paste this line: sudo apt-get install mysql-server Step 2 (optional). In order for other computers on your network to view the server you have created, you must first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file. gksudo gedit /etc/mysql/my.cnf Change the line bind-address = 127.0.0.1 And change the 127.0.0.1 to your IP address. Step 3. This is where things may start to get tricky. Begin by typing the following into Terminal: mysql -u root Following that copy/paste this line: mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword'); (Make sure to change yourpassword to a password of your choice.) Step 4. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal: sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following: gksudo gedit /etc/php5/apache2/php.ini Now we are going to have to uncomment the following line by taking out the semicolon (. Change this line: ;extension=mysql.so To look like this: extension=mysql.so Now just restart Apache and you are all set! sudo /etc/init.d/apache2 restart
  4. Second one is an ideal case to design a table. Don't take Varchar as your primary key, if you don't want to make auto-increment then use any functions and create random key as a primary key, but not varchar.
  5. main book of PHP is php.net documentation on php.net, Please read each page and apply logic with sample code. I am sure you will never disappoint and get updated code. http://www.php.net/manual/en/
  6. Please change your input box name to "compmo" Because you element name and what you have written in the query are different.
  7. Hello, I haven't found any input element name is 'grad'.
  8. you can use <a > tag but if you are trying to do with .txt file then it's open in browser only not give a popup to download. Please visit below link and code to implement download file. http://php.net/manual/en/function.header.php <?php// We'll be outputting a PDFheader('Content-type: application/pdf');// It will be called downloaded.pdfheader('Content-Disposition: attachment; filename="downloaded.pdf"');// The PDF source is in original.pdfreadfile('original.pdf');?>
  9. This script resize an Image into two 60px and 25px. Take a look at $newwidth you have to modify size values. <?php define ("MAX_SIZE","400");$errors=0;if($_SERVER["REQUEST_METHOD"] == "POST"){ $image =$_FILES["file"]["name"];$uploadedfile = $_FILES['file']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['file']['name']); $extension = getExtension($filename); $extension = strtolower($extension);if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) {echo ' Unknown Image extension ';$errors=1; }else{ $size=filesize($_FILES['file']['tmp_name']);if ($size > MAX_SIZE*1024){echo "You have exceeded the size limit";$errors=1;}if($extension=="jpg" || $extension=="jpeg" ){$uploadedfile = $_FILES['file']['tmp_name'];$src = imagecreatefromjpeg($uploadedfile);}else if($extension=="png"){$uploadedfile = $_FILES['file']['tmp_name'];$src = imagecreatefrompng($uploadedfile);}else {$src = imagecreatefromgif($uploadedfile);}list($width,$height)=getimagesize($uploadedfile);$newwidth=60;$newheight=($height/$width)*$newwidth;$tmp=imagecreatetruecolor($newwidth,$newheight);$newwidth1=25;$newheight1=($height/$width)*$newwidth1;$tmp1=imagecreatetruecolor($newwidth1,$newheight1);imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1, $width,$height);$filename = "images/". $_FILES['file']['name'];$filename1 = "images/small". $_FILES['file']['name'];imagejpeg($tmp,$filename,100);imagejpeg($tmp1,$filename1,100);imagedestroy($src);imagedestroy($tmp);imagedestroy($tmp1);}}}//If no errors registred, print the success messageif(isset($_POST['Submit']) && !$errors) { // mysql_query("update SQL statement "); echo "Image Uploaded Successfully!";}function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext;}?>
  10. Please change your sql query. // Build SQL Query $query = "select * from the_table where 1st_field like '%".$trimmed."%' order by 1st_field"; // EDIT HERE and specify your table and field names for the SQL query Please try after change query.
  11. it's ternary operator which take place of if else statement. // in ternary operatorisset($_POST['cardType']) ? $_POST['cardType'] : '';// in if..elseif(isset($_POST['cardType'])){$cardType = $_POST['cardType'];}else{$cardType = '';} I hope you cleared.
  12. To hide Notice and warning, use error_reporting(0); on top of the page after any included and file and session start; It's good to use error_reporting(E_ALL);
  13. Please find the code below. <?php if(is_set($_POST['submit']) { //please conect and select db $query = mysql_query("insert into tabname values('valueofcnt','vouchercode')"; } $sql = mysql_fetch_row(mysql_query("SELECT counter_val from tabname ORDER BY counter_val DESC LIMIT 1")); ?> <form action="" method="post"> <input type="submit" name="submit" value="<?=$sql[0]?>"> </form>
  14. Hello, Your query saved as a resource id. To check and debug of your query output. use, var_dump($query); or you can use, print_r($query); You get the all rows details with data as an array.
  15. So, till file saved it's worked correctly. When user trying to login, you just read that file using file_get_contents() And search a pattern string which compare the user's input. You can find many string search functions in PHP.net I hope it would be helpful for you.
  16. Static method cannot call using $this operator after initiate the object of class One.
  17. Hey, It is best practice to write exit(); after each header() function.
  18. Hey, Could provide code for better understanding?
  19. Hello Friends, My self Chintan from pune, I have 4 years of architecture and development experiance in LAMP technoologies. I like to share ideas and give solution.
  20. Please use below sql string. $query = mysql_query('SELECT value FROM countries WHERE value LIKE "'.$queryString%.'" LIMIT 10');
  21. I feel string concatenation is not properly, Please replace with below string and then try. $q = 'SELECT * FROM tbl_svc_auto WHERE auto_model = "'.$model.'" AND '.$year.' BETWEEN auto_year AND auto_year_high'; I hope it worx.
  22. Hello, Please check following things. 1. File uploaded/created properly 2. Where you saved your $outputfile, give server path. 3. chmod, check path also 4. is_writable, please give a file path also. For, debugging mode, please put exit(); after chmod and run the script and check if file has 777 permission or not.
×
×
  • 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.