Scripting

Understanding how URLs are linked to Code in the HTML pages

Posted on

Whenever we launch a website in the browser, it then gets modified as we navigate the other elements on that web site page.  We notice that, the modified URL will mostly have the website actual website but with more strings attached to it starting with a ?. Example: We open a main web site  page say http://www.yahoo.com/ Then we navigate to Yahoo mail login page: https://login.yahoo.com/?.src=ym&.intl=us&.lang=en-US&.done=http://mail.yahoo.com    In the above we see the web site of yahoo.com is having URL with   https://login.yahoo.com/   +  ?  + .src=ym&.intl=us&.lang=en-US&.done=http://mail.yahoo.com   This process of URL modification is called the URL encoding.  This is […]

Advertisements
DataBase

Connecting to your MySQL Database from a Php page using PDO (PHP Data Objects)

Posted on

  In order to connect to a MySQL DB from Php, you need to frame the connection string and   Index.php <?php     include_once("config.php"); ?>   Config.php <?php     //set off all error for security purposes     error_reporting(E_ALL);         //define some contstant     define( "DB_DSN", "mysql:host=localhost;dbname=<myDBName>" );     define( "DB_USERNAME", "root" );     define( "DB_PASSWORD", "<myrootpasswordhere>" );     define( "CLS_PATH", "class" );     //include the classes     include_once( CLS_PATH . "/DBClass.php" ); ?>   DBClass.php <?php class DBClass {     public function Connect_mysqlDB(){         try {             $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );             $con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION […]