homeHome contactContact portfolioPortfolio musicMusic videoVideo historyHistory calendarCalendar rssRSS
karlpox | with GOD all things are possible

MySQL GUI Tools + WAMP

To integrate MySQL GUI tools on WAMP follow the instructions below.

1. Download the GUI Tools to be used on this page.
2. Download the one with the “Without installer (unzip in C:\)”.
3. Extract the one you have downloaded.
4. Copy it to your C:/wamp
5. Click on Start and then run.
6. Key in regedit then press enter.
7. Go to HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > wampmysqld
8. Right click on the ImagePath.
9. Take note of the value because the version of MySQL might change. For example mine is.

c:\wamp\bin\mysql\mysql5.0.51a\bin\mysqld-nt.exe

change it to

c:\wamp\bin\mysql\mysql5.0.51a\bin\mysqld-nt.exe –defaults-file=c:\wamp\bin\mysql\mysql5.0.51a\my.ini wampmysqld

Your MySQL GUI tools should work now. This solution also solves the Either the server service or the configuration file could not be found. Startup variables and service section are therefore disabled problem.

Using Sessions

How to use sessions

What is session anyways? According to php.net session is a “way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.” As for me session is like a super global array which can be passed to different pages using the session_start() function. Sessions are very useful especially an on page that requires users to be logged. Because sessions can track weather a user is still logged or not. So let’s get started using sessions in log in cases.

First of all you have to insert the session_start() function at the most top of your coded. So it must be found on line 0 of your codes. For example.

<?php session_start(); ?>

But some servers like mine displays error even if the session_start() is already at the most top of your code so you add this to your code to solve this problem.

<?php
session_cache_limiter(`nocache`);
session_start();
?>

And you need to do a session_start() on every page if you want the user to be logged in order to access the page. So now how do we determine if the session of the user is still active or not? So after you check if the username & password of the user is correct you create a session for the user to know if the user is still active or not. So after checking if the user is valid you do this.

<?php
$_SESSION[`active`] = true;
?>

The word `active` is not constant, you can change it to anything you want. You can even change it to something like $_SESSION[`weeee`] = active; it really doesn’t matter as long as you remember it. So to check if the user is still active, on every page that requires a user to be logged at the most top you do this. Read more »

A Simple Login Code using PHP+MySQL

First of all you must create a table. For a example we name this table as member.

id username password
1 karlo 123
2 toni 143

So first you must create your own form. That looks like any ordinary login box with a username, password and a login button.

<form method=”POST” action=”">
<p>
<label>Username: </label>
<input type=”text” name=”username” />
</p>
<p>
<label>Password: </label>
<input type=”password” name=”password />
</p>
<p>
<input type=”submit” value=”Login” />
</p>
</form>

As you can see i have set the action=”" to empty so you have to change it to something like process_login.php or any .php page that would verify if the user input is valid or not.
Read more »

Simple guide to PHP+MySQL

Well to solve some of your problems here are some easy guides on how to connect yo MySQL using PHP.

 

first of all this guides uses WAMP you can download it @ WAMP SERVER.

 

So after installing WAMP. You would first need to create a database. Its easy all you have to do is go to http://localhost/phpmyadmin and you can see the create database button there. Just input the database name you want then press create.

 

Afterwards you have to choose your database on the right side and lets start creating some table!

 

First create a simple notepad. And put this codes in side the notepad and save it as anything you want.

 

Create table member
(
m_id int unsigned not null auto_increment primary key,
username varchar(100) not null,
password varchar(100) not null
);
 

 

This means you will create a table with the name of member. With attributes m_id as a unsigned integer and its default value is not null this attribute also does auto_increment and is your primary key for this table. Next you have the m_username & m_password as varchar with a maximum character size of 100 and its not null too.

 

After saving this you will need to import them using phpMyAdmin. You can easily see the import button on the header of phpMyAdmin. After selecting the file and importing voila you have your very own table!

 

To simply add data into your table you must first creat a form. Well i know you can do this without me teaching you. So next after clicking on the submit button you would be directed to the next page and this is where the coding starts!

 

Lets store the datas posted first into variables.

 

$username = $_POST['username'];
$password = $_POST['password'];

 

username & password is not constant it simply depends on whats the name of the input you have coded in the form.

 

Next you have to conncet to a database.

 

$dbhost = ‘localhost’;
$dbuser = ‘dcwarez_karlpox’;
$dbpass = ’secret’;
$db=mysql_connect($dbhost, $dbuser, $dbpass) or die(’Error connecting to mysql’) or die(’Error : ‘ . mysql_error());
$dbname = ‘example’;
mysql_select_db($dbname) or die(’Error : ‘ . mysql_error());

 

Well this code simply means that i have connected to the mysql database with those information. And choose the example as my database (lets just say you have created example as database name from above). Now if you would probaby be wondering whats that dcwarez_karlpox is and secret. Well those are priveledges. You can create them on the phpMyAdmin home page. A priveledge link can be seen there and you have to create your own user. But you can still use the default user which is

 

$dbuser = ‘root’;
$dbpass = ”;

 

With those information above you can connect to a MySQL if you are using WAMP.

 

Now to add datas in your table you can simply do this query

$q="insert into member (m_username,m_password) values (’".$username."’, ‘".$password."’)";

$r=mysql_query($q);

 

Take not that i didnt include the m_id. Simply because its already auto_increment you dont have to add data into it anymore.

Next is to View data from a table you simply do this code.

 

$q="select * from member"

$r=mysql_query($q);

while($row=mysql_fetch_array($r,MYSQL_ASSOC))

{

echo ‘Username: ‘.$row['username'].’ Password: ‘.$row['password'].’<br/>’;

}

 

This code will output all the username and password under  the member table. To get specific datas only you do this by using the where and like functions. Example.

 

$q="select * from member where m_username like ‘karlo’ and m_password like ’sobiaco’;

$r=mysql_query($q);

$row=mysql_fetch_array($r,MYSQL_ASSOC));

echo ‘Username: ‘.$row['username'].’ Password: ‘.$row['password'].’<br/>’;

 

Take note that i didnt use any looping for this. Simply because you are using a member table and you must not have any duplicates in right? Well its your job to find a way to avoid duplicates!

 

Next is to delete data from a database. You simply do this by this code.

$q="delete from member where m_username like ‘karlo’;

$r=mysql_query($q);

This code simply deletes all the rows in the table member that has a m_username of karlo.

 

Lastly we have the UPDATE. To do this just analyze the code below.

 

$q="update member set m_username = ‘karlpox’ where m_username like ‘karlo’";

$r=mysql_query($q);

 

This code simply updates all m_username with a value of karlo into karlpox. You can also update more datas by using this query.

 

$q="update member set m_username = ‘karlpox’, m_password=’12345′ where m_username like ‘karlo’";

 

Now that query replaces both the m_username & m_password of m_username’s which has a value of karlo.

 

Thats all!