PHP scripts and programs for Beginner to Master

php programs, php ready to use scripts & functions, css tutorials, html, javascripts, ajax examples for Beginner to Master

Whenever you are working on a project you might need to create a database connection and select a database.

Here i am going to show you a simple way to create your connection file "connect.php"
First create a file and save it as "connect.php"






Now save this file.
Now just include this file on top of your any other php script.
No need to write code each time.
ex. create a new file called "data.php" and include "connect.php" in that file on top as



Have nice time.

How to get IP in php ?

While working on a project you might need a dynamic select box to be generated from the values present in the database.
So this example gives you a simple way to populate a select box with the values present in the database.

Consider a example - there is a table "article" in your database "mydb"

So for this first we need to create a connection with the database and we need to select the database.

For this we will create a file called "connect.php"

replace the values with your actual values as per directed in code



After that we will write our main code in a file called "myselect.php"



And its over. Its very simple.
Try it out, if you face any problem then comment here, i will help you.

Show a-z links on a page for pagination




You can replace $PHP_SELF with the filename for which you want to generate this pagination.
Ofcourse this code doesnt shows the logic to display actually pagination, but instead of taking characters from a-z in a array this is the simple way to show a-z characters for processing.

Soon even i will publish the code to do actual pagination.

[Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in]


Hi,
when you are doing programming in php you might be getting a error like

[Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in] 

this in your php script.

Most of the times if there is mistake in spelling then many errors occurs.

Just check out following things if you encounter this kind of Warning in your php program

  1. First check your query.
  2. If you are using different connection file for creating connection then check whether it is included in your script or not.
  3. If query is correct then check your Database Connection.