Posts

Showing posts from September, 2015

Insert Data in Database through pdo in php..

try {  $db = new PDO('mysql:host=localhost;dbname=idegraphics', 'root', '');  $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); }catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } $radio=$_POST["radio1"]; $descr=$_POST["descr"]; $yrreg=$_POST["select"]; $carmodel=$_POST["mot"]; $fuel=$_POST["fuel"]; $variant=$_POST["variant"]; try {     $stmt = $db->prepare("insert into motorscustomer(cardetails,registartiondetails,yearofregistation,cardetailsname,fueltype,variantype) values(?,?,?,?,?,?)");     $stmt->execute(array($radio,$descr,$yrreg,$carmodel,$fuel,$variant)); $last_id = $db->lastInsertId();   //  echo "New record created successfully. Last inserted ID is: " . $last_id; }catch(PDOException $e) {     echo 'ERROR: ' . $e->getMessage(); }

Rating Bar in Android.

Image
 rates = (EditText) findViewById(R.id.rates);                         rates.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(rates.getText().length()>0) { ratingBar.setRating(Float.parseFloat(rates.getText().toString())); rating_val.setText(String.valueOf(rates.getText().toString())); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { } });

Import csv file data in database through PHPExcel.

<?php error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>PHPExcel Reader Example #01</title> </head> <body> <h1>PHPExcel Reader Example #01</h1> <h2>Simple File Reader using PHPExcel_IOFactory::load()</h2> <?php $connection=mysql_connect("127.0.0.1","root",""); mysql_select_db("idegraphics",$connection); /** Include path **/ set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); /** PHPExcel_IOFactory */ include 'PHPExcel/IOFactory.php'; $inputFileName = './sampleData/vmpc.csv'; echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />'; $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); $sh

Call Curl in php.

$ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "www.abc.com"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch);