Pages

Wednesday, March 6, 2013

Error while connecting to the mysql databse with php whereas username and password are correct

Some time you face this problem specially new programmers while connecting to the mysql database that they are not able to connect it to the database on their hosting server whereas their username and password they have created are correct. So what the thing they missed out?

Its the hosting service prefix

whenever you are in any hosting serivice its having a username prefix for example

user login for hosting service bibo123 and password *******

so whenevr you create a database and new user to that hosting account it will prefic the bibo123_ on that database name and username too. So if you are having a database name student it will prefix the bibo123_ to it and it will become bibo123_student. so as it will do with the username also. for description their is an example below to connect to mysql database

hosting login: bibo123_
username you created: jinah
password: pikachu


$username = bibo123_jinah;
$password = bibo123_password
mysql_connect("localhost", $username, $password) or die(mysql_error());
echo "Connected to MySQL
";
try it.



posted by honeyonsys

Print the next highest integer value by rounding up value with javascript

To convert a decimal value like 4.5 to a round value to its nearest decimal integer we have three main function in the javascript library

Math.ceil() = Round a number upward to it's nearest integer:
Math.round() = Round a number to the nearest integer:
Math.floor() = Round a number downward to its nearest integer:



Round() example

var a=Math.round(2.60);
var b=Math.round(2.50);
var c=Math.round(2.49);
var d=Math.round(-2.60);
var e=Math.round(-2.50);
var f=Math.round(-2.49);

Result

3
3
2
-3
-2
-2


Ceil() example

var a=Math.ceil(0.60);
var b=Math.ceil(0.40);
var c=Math.ceil(5);
var d=Math.ceil(5.1);
var e=Math.ceil(-5.1);
var f=Math.ceil(-5.9);

Result

1
1
5
6
-5
-5


floor() example

var a=Math.floor(0.60);
var b=Math.floor(0.40);
var c=Math.floor(5);
var d=Math.floor(5.1);
var e=Math.floor(-5.1);
var f=Math.floor(-5.9);

Result

0
0
5
5
-6
-6

Print the next highest integer value by rounding up value with php

To make a round value from an decimal value like:

3.4 to 4
5.6 to 6

you can use the php ceil function, ceil - Round fractions down

its syntax is float ceil ( float $value )

example 

echo ceil(3.4);    // 4
echo ceil(9.999);  // 10


for a value Round fraction down you can use the floor()

example

echo floor(4.3);   // 4
echo floor(9.999); // 9
echo floor(-3.14); // -4


and one is the round() function which returns the nearest round value to the decimal

echo round(3.4);         // 3
echo round(3.5);         // 4
echo round(3.6);         // 4
echo round(3.60);      // 4
echo round(1.955832);  // 1.96
echo round(1241757, -3); // 1242000
echo round(5.0452);    // 5.05
echo round(5.0552);    // 5.06


for more detail or reference you can see the detail documentation on http://www.php.net/manual/en/function.round.php


posted by honeyonsys

Tuesday, March 5, 2013

How to make gradient effect with css only (without using image)

You can use this trick to make a
background like a gradient with using only css (no background image needed). the code is here


you will get the out put as follows



you can use -webkit- and -moz- for mozilla or other unsupportive style browser. but this cant be work in below IE9.

test it :).



posted by honeyonsys

Sunday, March 3, 2013

How to enable text format toolbar in tinymce editor

To enable or display font editor toolbar you need to add the few lines into your tinyMCE.init() function.


tinyMCE.init({
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
)};


posted by honeyonsys

About Me

Hi,My name is Harish Kumar.I am a web developer by profession.I am working in the same field since 2008. About my skills i am proficient in HTML,CSS,JAVASCRIPT/JQUERY/ ANGULAR,PHP,MYSQL,APACHE,LINUXAJAX, REST,etc...