PHP n MySQL connection

This is a discussion on "PHP n MySQL connection" within the PHP Forum section. This forum, and the thread "PHP n MySQL connection are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Apr 15th, 2007, 08:30
New Member
Join Date: Mar 2007
Location: UK
Age: 26
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP n MySQL connection

using MySQL n PHP together how can I manage database connection?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Apr 18th, 2007, 06:41
New Member
Join Date: Jul 2006
Location: Wichita, KS
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP n MySQL connection

Hi uddin,

PHP with MYSQL is a good combination when compared to others.



Code: Select all

 <?php
ob_start();
}
<html>
<body>
<form name = frm action = <?php echo $_SERVER['PHP_SELF']; ?> method = "post"> 
Employee number: <input type = text name = empno> <br>
Employee Name : <input type = text name = empname> <br>
<input type = submit value = "save">
</form>
</body> 
</html>
<?php
$con = @mysql_connect("localhost", "username","password") or die(mysql_error());
$db = @mysql_select_db("emp",$con) or die(mysql_error());
if(isset($_POST['empno'] or isset($_POST['empname'])) 
{
$qry = "insert into empdet (empno, empname) values (".$_POST['empno'].", '".$_POST['empname']."')";
$res = @mysql_query($qry) or die(mysql_error());
If($res>0)
{
header("location:success.php");
}
}
@mysql_close($con);
ob_end_flush();
?>
Use the code above or modify as needed.

Thanks!!!

_________________________________________

www.realmetrics.com - Metrics you can count on
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
connection

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Connection String Info Monie Classic ASP 9 Oct 24th, 2007 01:48
Asp to MSAcess connection? tolis Classic ASP 6 Oct 19th, 2007 07:12
DB connection problem Strike Classic ASP 1 Jul 4th, 2006 09:45
another database connection question! asp and mysql fogofogo Classic ASP 4 Dec 2nd, 2005 08:48
dns less connection String djaccess Classic ASP 7 Oct 5th, 2003 14:34


All times are GMT. The time now is 04:53.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42