viernes, 21 de noviembre de 2014

Como reparar una tabla MYSQL

En este caso vamos a reparar la tabla  kvstore en la base de datos asterisk.
mysqlcheck asterisk kvstore --auto-repair -p

 mysqlcheck -u root -p --auto-repair -c -o --all-databases
http://www.thegeekstuff.com/2011/12/mysqlcheck/

miércoles, 19 de noviembre de 2014

Script para extraer cantidad de tiempo transcurrido

<?php
require ("./library/conect.php");

$result = mysql_query("SELECT timediff(now(),date) AS time,date,phone,advnumber FROM `leads` where `campaign` ='o65' order by date asc");
echo "Total de records ".mysql_num_rows($result );
echo "<table border='1'>
<tr>
<th>ID</th>
<th>STATE</th>
<th>TIME</th>
<th>TIME</th>
<th>ELIMINAR</th>
</tr>";
   while($row = mysql_fetch_array($result))
    {
  echo "<tr>";
 echo "<td>" . $row['phone']."</td>";
  echo "<td>" . $row['advnumber'] . "</td>";
  echo "<td>" .  $row['time'] . "</td>";
  echo "<td>" .  substr($row['time'],-5,2). "</td>";  //extrayendo solo los minutos transcurridos
echo "<td><a href=?ID=$row[recordid]>" ."ELIMINAR" . "</td></a>";
  echo "</tr>";
$GLOBALS['b']= $row['time'];     // declaramos la Variable global para tener acceso en todo el script
}

echo "</table>";
echo $b;
mysqli_close($con);
?>

sábado, 15 de noviembre de 2014

Backup and Restore MySQL Database Using mysqldump

 
mysqldump -d -h localhost -u root -p1233 insurance > insurance.sql
mysqldump -d -h localhost -u root -p1233 asterisk> asterisk.sql



How To Restore MySQL database


1. Restore a database

In this example, to restore the sugarcrm database, execute mysql with < as shown below. When you are restoring the dumpfilename.sql on a remote database, make sure to create the sugarcrm database before you can perform the restore.
# mysql -u root -ptmppassword

mysql> create database sugarcrm;
Query OK, 1 row affected (0.02 sec)

# mysql -u root -ptmppassword sugarcrm < /tmp/sugarcrm.sql

# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
 
 


http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/

viernes, 7 de noviembre de 2014

Activando el short_open_tag = On

Si queremos que nuestros script sean reconocidos  <? ?> y no tener que escribirlo de la siguiente manera <?php ?>


Editar los arhicos php.ini
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini
activar el short_open_tag
short_open_tag = On
/etc/init.d/apache2 restart

sábado, 4 de octubre de 2014

PHP Javascript Alert Box


<?
 echo '<script language="javascript">';
 echo 'alert("Incomming call from 1111111111\n Jose")';
 echo '</script>';


?>

How to make text blink with JavaScript and CSS3


Author: | Posted in Tutorials No comments
At some point you might come across a situation where you have to use a blinking text in your website or a project. We know blinking text or marquee scrolling is out of date and isn’t really recommended these days for website design but that’s what your client wants, and there’s nothing you can do about it, so you decide to do it.
There used to be CSS property called “text-decoration” and HTML tag “blink” that allowed you to do that easily, but modern browsers these days doesn’t support them anymore. so only option left is to use jQuery for that. Here in this tutorial I’m going to show you a very simple trick you can use to make text blink with JavaScript and CSS3.

jQuery
CSS

HTML
I am using setInterval function and toggle function to blink text in this tutorial. As you can see, the “blink” class is added on the “P” element which contains the text that we wanted to blink, and between the interval of 500 milliseconds the “blink” class gets added and then removed.
By default we have set the “P” element to have CSS3 transition property which creates the fade in and fade out effect every time a property changes and the class “blink” has the css property of color set to be transparent meaning it makes the text invisible, so every time the “blink” class is added the text becomes invisible and then visible again when the “blink” class is removed.
This is a really simple way to do this and might be useful sometimes.

http://www.andwecode.com/blink-text-using-simple-javascript-css3/#tab-4820-demo

POPUP WINDOW

<br><center><b>
<a href="" onclick="window.open('google.com','name','width=400,height=500')">Voices list</a></b></center>

Add edit delete rows dynamically using jquery and php

http://www.amitpatil.me/add-edit-delete-rows-dynamically-using-jquery-php/

http://www.jqueryrain.com/example/jquery-ajax-example/page/4/

Here is the live demo http://www.amitpatil.me/demos/add-edit-delete-rows-dynamically-using-jquery-and-php/with-drop-down/ and download it from here http://www.amitpatil.me/demos/add-edit-delete-rows-dynamically-using-jquery-and-php/Ajax-table-with-drop-down.zip - See more at: http://www.amitpatil.me/add-edit-delete-rows-dynamically-using-jquery-php/#sthash.44BTTzMs.dpuf


Here is the live demo http://www.amitpatil.me/demos/add-edit-delete-rows-dynamically-using-jquery-and-php/with-drop-down/ and download it from here http://www.amitpatil.me/demos/add-edit-delete-rows-dynamically-using-jquery-and-php/Ajax-table-with-drop-down.zip - See more at: http://www.amitpatil.me/add-edit-delete-rows-dynamically-using-jquery-php/#sthash.44BTTzMs.dpuf
 

Here is the live demo http://www.amitpatil.me/demos/add-edit-delete-rows-dynamically-using-jquery-and-php/with-drop-down/ and download it from here http://www.amitpatil.me/demos/add-edit-delete-rows-dynamically-using-jquery-and-php/Ajax-table-with-drop-down.zip - See more at: http://www.amitpatil.me/add-edit-delete-rows-dynamically-using-jquery-php/#sthash.44BTTzMs.dpuf

(Ubuntu - Lamp) Why exist in Ubuntu lamp 2 PHP.ini files?

PHP can be executed from the command line or from a webserver. /etc/php5/apache2/php.ini is used for the webserver execution, /etc/php5/cli/php.ini is used for the command line execution.

http://superuser.com/questions/147743/ubuntu-lamp-why-exist-in-ubuntu-lamp-2-php-ini-files

martes, 30 de septiembre de 2014

Generate Random 10 Digit Number in PHP

Generate Random 10 Digit Number in PHP
PHP, Quick Tips 40 Comments

The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:
?
1
  
$random = substr(number_format(time() * mt_rand(),0,'',''),0,10);

Here’s whats happening with the code:

The outer portion “substr” is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.

The “number_format” function helps get rid of the scientific notation that will arise from generating the random number. In the middle, “time()” and “mt_rand()” are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.

Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.


- See more at: http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#sthash.WrvYJJBc.dpuf

Generate Random 10 Digit Number in PHP

PHP, Quick Tips 40 Comments
The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:
?
1
$random = substr(number_format(time() * mt_rand(),0,'',''),0,10);
Here’s whats happening with the code:
The outer portion “substr” is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.
The “number_format” function helps get rid of the scientific notation that will arise from generating the random number. In the middle, “time()” and “mt_rand()” are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.
Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.
- See more at: http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#sthash.WrvYJJBc.dpuf

Generate Random 10 Digit Number in PHP

PHP, Quick Tips 40 Comments
The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:
?
1
$random = substr(number_format(time() * mt_rand(),0,'',''),0,10);
Here’s whats happening with the code:
The outer portion “substr” is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.
The “number_format” function helps get rid of the scientific notation that will arise from generating the random number. In the middle, “time()” and “mt_rand()” are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.
Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.
- See more at: http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#sthash.WrvYJJBc.dpuf

Generate Random 10 Digit Number in PHP

PHP, Quick Tips 40 Comments
The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:
?
1
$random = substr(number_format(time() * mt_rand(),0,'',''),0,10);
Here’s whats happening with the code:
The outer portion “substr” is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.
The “number_format” function helps get rid of the scientific notation that will arise from generating the random number. In the middle, “time()” and “mt_rand()” are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.
Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.
- See more at: http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#sthash.WrvYJJBc.dpuf

Generate Random 10 Digit Number in PHP

PHP, Quick Tips 40 Comments
The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:
?
1
$random = substr(number_format(time() * mt_rand(),0,'',''),0,10);
Here’s whats happening with the code:
The outer portion “substr” is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.
The “number_format” function helps get rid of the scientific notation that will arise from generating the random number. In the middle, “time()” and “mt_rand()” are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.
Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.
- See more at: http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#sthash.WrvYJJBc.dpuf

Generate Random 10 Digit Number in PHP

PHP, Quick Tips 40 Comments
The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:
?
1
$random = substr(number_format(time() * mt_rand(),0,'',''),0,10);
Here’s whats happening with the code:
The outer portion “substr” is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.
The “number_format” function helps get rid of the scientific notation that will arise from generating the random number. In the middle, “time()” and “mt_rand()” are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.
Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.
- See more at: http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#sthash.WrvYJJBc.dpuf

Generate Random 10 Digit Number in PHP

PHP, Quick Tips 40 Comments
The application I’m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:
?
1
$random = substr(number_format(time() * mt_rand(),0,'',''),0,10);
Here’s whats happening with the code:
The outer portion “substr” is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.
The “number_format” function helps get rid of the scientific notation that will arise from generating the random number. In the middle, “time()” and “mt_rand()” are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.
Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.
- See more at: http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#sthash.WrvYJJBc.dpuf

Foreign key MYSQL PHPMYADMIN

https://www.youtube.com/watch?v=J3xvwhqYYMQ
CASCADE
Whenever rows in the master (referenced) table are deleted (resp. updated), the respective rows of the child (referencing) table with a matching foreign key column will get deleted (resp. updated) as well. This is called a cascade delete (resp. update[2]).
RESTRICT
A value cannot be updated or deleted when a row exists in a foreign key table that references the value in the referenced table. Similarly, a row cannot be deleted as long as there is a reference to it from a foreign key table.
NO ACTION
NO ACTION and RESTRICT are very much alike. The main difference between NO ACTION and RESTRICT is that with NO ACTION the referential integrity check is done after trying to alter the table. RESTRICT does the check before trying to execute the UPDATE or DELETE statement. Both referential actions act the same if the referential integrity check fails: the UPDATE or DELETE statement will result in an error.
SET NULL
The foreign key values in the referencing row are set to NULL when the referenced row is updated or deleted. This is only possible if the respective columns in the referencing table are nullable. Due to the semantics of NULL, a referencing row with NULLs in the foreign key columns does not require a referenced row.
SET DEFAULT
Similar to SET NULL, the foreign key values in the referencing row are set to the column default when the referenced row is updated or deleted.

MYSQL JOINS

MySQL JOINs: An Introduction

This article is started with MySQL simple JOIN concept with PHP script. JOINs in database queries are used to retrieve data from more than one table using single query. On executing the join query, this will return a table in virtual manner which is not present  in database actually. For example, let there are two table in database namely tbl_links, tbl_categories and their structure is like as below format.
mysql_join
tbl_links
+----------+---------------+----------------+
| links_id | links_name    | links_category |
+----------+---------------+----------------+
| 1        | google.com    | 3              |
| 2        | phppot.com    | 1              |
| 3        | facebook.com  | 2              |
+-----------------+-------------------------+

tbl_tags
+--------+-------------------+
| tag_id | tag_name          |
+--------+-------------------+
| 1      | PHP               |
| 2      | Social Networking |
| 3      | Search Engine     |
| 4      | Java              |
+-----------------+----------+
The tbl_links table has links_category field as it’s foreign key where the primary key tag_id of tbl_tags will be stored here. Now we can create a table of data which is spread over these two tables, by comparing these two keys. For that, we are going to use MySQL JOINS as shown below.
$query = SELECT a.links_name, b.tag_name FROM tbl_links a, tbl_tags b WHERE a.links_category = b.tag_id
Before executing this query using PHP, we need to connect the database, about what we have discussed already in Access MySQL from PHP. This query will result a table to be displayed to the browser as follows.
tbl_links
+---------------+-------------------+
| links_name    | tag_name          |
+---------------+-------------------+
| google.com    | Search Engine     |
| phppot.com    | PHP               |
| facebook.com  | Social Networking |
+-----------------+-----------------+

Types of JOINs

There are several type of JOINs in MySQL. These are,
  • Inner JOIN – It is simple JOIN to to get common data between two tables as shown in this article.
  • Outer JOIN – It is also called as Full Outer JOIN, which will retrieve all the rows from both tables and represent NULL for the column index, if the condition of the JOIN is not satisfied.
  • Left JOIN – Retrieves all the rows from left table and display the data from other table if the condition is satisfied. Otherwise, it will display NULL.
  • Right JOIN – It is similar to Left JOIN, but works with respect to right table instead of left one.

Note:

MySQL JOINS can be applicable for SELECT, UPDATE and DELETE queries.
This MySQL tutorial was added on April 27, 2013.

http://phppot.com/php/mysql-joins-an-introduction/