Thursday 23 May 2013

Excel To Mysql using PHP through CSV file format.


PRELIMES:                 METHOD:1
--------
Excel to csv convertion . create table in mysql
----------

csv to mysql table data import:  100% succcess.  
------------------------------- --------------->>

<?php
$sql=mysql_connect("localhost","root","");   //hostname,username,password
 mysql_select_db("test",$sql); // employee is the database name.
 $path = "list.csv"; // csv file in the same directory
  if (($handle = fopen($path, "r")) !== FALSE)
 {
$i=1;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
 {
echo $data[0],$data[1];
    mysql_query("insert into t1(name,mailid) values('".$data[0]."','".$data[1]."')");//t1->table name and its files names

echo $i;$i++;
echo "<br >";

  }
     fclose($handle);
}
?>

------------------------------------------------------------------------------


METHOD : 2
===========
working : text file to mysql data insert
LOAD DATA INFILE 'c:/wamp/www/touch/text.txt' INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES(name,email)
 Excel->csv,txt to mysql table data import 90% scuccess.
=================================================>
PRELIMES:
--------
Excel to csv convertion . create table in mysql
---------------------------------

Short and sweet solution for excel to mysql data import:
Working good for txt file formats. IN DETAIL:
tbl name=t1 feilds are= name varchar,email varchar;
text.txt file <<== this text file first lines table column names:
name, email "n1", "e1" "n2", "e2" "n3", "e3" "n4", "e4" "n5", "e5" "n6", "e6" "n7", "e7"
SQL query in wamp

LOAD DATA INFILE 'c:/wamp/www/touch/text.txt' INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES(name,email)

For this commnad run successfully we have create folders for separately.

Real one is

C:\wamp\mysql\data\wamp\www\touch\text.txt <<==pysical file path is.

But we mention c:/wamp/touch/text.txt
------------------------------------------------------------------------------------------------------------

Tuesday 21 May 2013

Insert and Extract image in php mysql database

This post contain one create table data,2 html files and 2 php files for insert and extract image in database.


Table name=tbl_images database name=test,username=root,password=""
----------------------


mysql> CREATE TABLE tbl_images (
> id tinyint(3) unsigned NOT NULL auto_increment,
> image blob NOT NULL,
> PRIMARY KEY (id)
> );


upload image
===========

add.html
--------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form enctype="multipart/form-data" action="insertimage.php" method="post" name="changer">
<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input name="image" accept="image/jpeg" type="file">
<input value="Submit" type="submit">


</body>
</html>


insertimage.php
---------------
<?php
// Create MySQL login values and
// set them to your login information.
$username = "root";
$password = "";
$host = "localhost";
$database = "test";

// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}

// Select your database
mysql_select_db ($database);
// Make sure the user actually
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {

// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];

// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);


// Create the query and insert
// into our database.
$query = "INSERT INTO tbl_images ";
$query .= "(image) VALUES ('$data')";
$results = mysql_query($query, $link);

// Print results
print "Thank you, your file has been uploaded.";

}
else {
print "No image selected/uploaded";
}

// Close our MySQL Link
mysql_close($link);
?>




Show/display image in php mysql
================================

show.html
----------


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>show image</title>
</head>

<body>
<form method="post" action="show.php">
Select employee id:<input type="text" name="id"  />
<input type="submit" value="submit" />
</form>
</body>
</html>



show.php
---------

<?php

$username = "root";
$password = "";
$host = "localhost";
$database = "test";

mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());

mysql_select_db($database) or die("Can not select the database: ".mysql_error());

$id =$_POST['id'];
/*
if(!isset($id) || empty($id) || !is_int($id)){
     die("Please select your image!");
}else{*/
//echo $id;
$query = mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['image'];


//$var_value = $_POST['$content'];
header('Content-type: image/jpg');
//header( 'Location: showw.php' ) ;
//

/*echo '<form method="POST" action="Page2.php?myVariable='.
    urlencode($myVariable).'">";*/

echo $content;
    // echo $content;
//}

?>







Saturday 18 May 2013

The requested URL /phpmyadmin was not found on this server in windows

I tried to open my phpmyadmin with IP address.

The error thrown "The requested URL /phpmyadmin was not found on this server in windows"

solution is

Check firewall is off,
put your wamp in Onlilne mode,
Edit the php alias file.This one new one.

Install Wamp,
exit it
Run notepad as administrator
go to C:\wamp\alias\phpmyadmin.conf
edit this line of code

AllowOverride all
Order Allow,Deny
Allow from all
Allow from 127.0.0.1


by default it was the problem:
-------------------------

AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1





Monday 6 May 2013

Showing Splash Screen At The Start Of Android PhoneGap Application

If you want to disaplay a splash screen at the beginning of Phonegap based Android application you need to put splash screen image(splash.png) inside res\drawable-hdpi,  res\drawable-mdpi,  res\drawable-idpi which can be located inside your project directory.
The splash screen image size should be different for different size of Android devices.
(same size image also worked)

For large screens size (hpdi) image size should be at least 640dp x 480dp
For normal screens size (mdpi) image size should be at least 470dp x 320dp
For small screens size (idpi) image size should be at least 426dp x 320dp
After putting the images in respective directory you need to add the the following code in your main Activity.java file before super.loadUrl method.
 super.setIntegerProperty("splashscreen", R.drawable.splash);
Then modify the super.loadUrl method to display the splash screen for 10 seconds before starting of the Phonegap application like this
 super.loadUrl("file:///android_asset/www/index.html", 10000);
So after modification your main Activity.java will look like this
package com.mindfire.HelloWorld;

import android.os.Bundle;
import org.apache.cordova.*;

public class RemindMeActivity extends DroidGap {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setIntegerProperty("splashscreen", R.drawable.splash);
        super.loadUrl("file:///android_asset/www/index.html", 10000);

//No need three line code         

    }
}





120 
down vote accepted

--------------------
In order to have a splash screen in a PhoneGap Android application you need to put your splash.png file into res/drawable-ldpi, res/drawable-mdpi, res/drawable-hdpi, 
res/drawable-xhdpi. 
Where those directories represent low, medium, high and extra large dots per inch. You'll need to resize you slash.png for each directory or
Android will stretch it for you.

The sizes of each image should be:

xlarge (xhdpi): at least 960 x 720
large (hdpi): at least 640 x 480
medium (mdpi): at least 470 x 320
small (ldpi): at least 426 x 320


Then in your main Java class, the one that extends DroidGap, you'll need to add one line and modify another. First add:

super.setIntegerProperty("splashscreen", R.drawable.splash);this line should show up under super.onCreate but before super.loadUrl. Then you'll need to modify your loadUrl method to pause for 5 seconds before loading up the main page. It would look like this:
super.loadUrl("file:///android_asset/www/index.html", 5000);That should do it for you.


I've recently made some updates to how the SplashScreen works on PhoneGap Android. The main app now loads while the splash screen is being shown. 
This is a big improvement over the previous blocking splash screen call. Read more about the changes on my blog.












2 down vote  page loading before splash screen
-----------------------------------------------
In my Phonegap app, Android version, Eclipse debugger throws tantrums if you set the splash screen or even the 'loading' dialog before calling loadUrl.

Both will work in the actual app installed on a device, but they will break your debugging. So I've put them behind loadUrl, 
where they can do no harm and still show well before the app itself.

public class App extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/index.html",5000);
    super.setStringProperty("loadingDialog", "Starting your app...");
    super.setIntegerProperty("splashscreen", R.drawable.splash);
    ...
}...

React + Typescript_ Module federation _ Micro Front end -Standalone and integrated

Module Federation The Module Federation is actually part of Webpack config. This config enables us to expose or receive different parts of t...