troubleshooting Question

Php not Updating SQK Database

Avatar of edavo
edavoFlag for United States of America asked on
PHPMySQL Server
9 Comments2 Solutions202 ViewsLast Modified:
This should be easy for experts.

The code below is from a tutorial and everything works except it is not UPDATING The data base. You can see the page here:

http://bbsidekick.com/bb/index_edit_test.php

<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="style.css" rel="stylesheet" type="text/css">
<style>
@import "http://fonts.googleapis.com/css?family=Droid+Serif";
/* Above line is used to import Google font style */
.maindiv{
margin:0 auto;
width:980px;
height:500px;
background:#fff;
padding-top:20px;
font-size:14px;
font-family:'Droid Serif',serif
}
.title{
width:100%;
height:70px;
text-shadow:2px 2px 2px #cfcfcf;
font-size:16px;
text-align:center;
font-family:'Droid Serif',serif
}
.divA{
width:70%;
float:left;
margin-top:30px
}
.form{
width:400px;
float:left;
background-color:#f0f8ff;
font-family:'Droid Serif',serif;
padding-left:30px
}
.divB{
width:100%;
height:100%;
background-color:#f0f8ff;
border:dashed 1px #999
}
.divD{
width:200px;
height:480px;
float:left;
background-color:#f0f8ff;
border-right:dashed 1px #999
}
#form3{
color:green;
font-weight:700
}
p{
font-weight:700;
text-align:center;
color:#5678C0;
font-size:18px;
text-shadow:2px 2px 2px #cfcfcf
}
form h2{
text-align:center;
text-shadow:2px 2px 2px #cfcfcf
}
textarea{
width:250px;
height:60px;
border-radius:1px;
box-shadow:0 0 1px 2px #123456;
margin-top:10px;
padding:5px 0;
border:none
}
.input{
width:250px;
height:15px;
border-radius:1px;
box-shadow:0 0 1px 2px #123456;
margin-top:10px;
padding:5px 0;
border:none;
margin-bottom:20px
}
.submit{
color:#fff;
border-radius:3px;
background:#1F8DD6;
padding:5px;
margin-top:40px;
border:none;
width:100px;
height:30px;
box-shadow:0 0 1px 2px #123456;
font-size:16px
}
a{
text-decoration:none;
font-size:16px;
margin:2px 0 0 30px;
padding:3px;
color:#1F8DD6
}
a:hover{
text-shadow:2px 2px 2px #cfcfcf;
font-size:18px
}
.clear{
clear:both
}
</style>
</head>
<body>
<div class="maindiv">
<div class="divA">
<div class="title">
<h2>Update Data Using PHP</h2>
</div>
<div class="divB">
<div class="divD">
<p>Click On Menu</p>
<?php
	$host="localhost"; 					// Put host name in a variable
	$username="bb2014"; 				// Put mysql username in a variable
	$password="sidekick2014"; 			// Put mysql password in a variable
	$db_name="bbsidekick"; 			// Put database name in a variable
	$tbl_name="posts"; 				// Put table name in a variable
		
	$connection = mysql_connect("$host","$username","$password"); 		// VITAL - Connect info: host/user/password
	mysql_select_db("$db_name")or die("cannot select DB"); 		// Select proper DB
	
if (isset($_GET['submit'])) {
$id = $_GET['id'];
$active = $_GET['active'];
$orderid = $_GET['orderid'];
$head = $_GET['head'];
$body = $_GET['body'];
$user = $_GET['user'];

$query = mysql_query('UPDATE posts SET
active="$active", orderid="$orderid", head="$head", body="$body", use="$user" where id="$id"', $connection);
}
$query = mysql_query('select * from posts', $connection);
while ($row = mysql_fetch_array($query)) {
echo '<b><a href="index_edit_test.php?update='.$row["id"].'">'.$row["head"].'</a></b>';
echo '<br />';
}
?>
</div><?php
if (isset($_GET['update'])) {
$update = $_GET['update'];
$query1 = mysql_query("select * from posts where id=$update", $connection);
while ($row1 = mysql_fetch_array($query1)) {
echo '<form class="form" method="get">';
echo '<h2>Update Form</h2>';
echo '<hr/>';
echo $row1["id"];
echo ' hdgfgkshdkjahdkahdsoiah ';
echo '<input class="input" type="hidden" name="did" value="'.$row1["id"].'" />';
echo '<br />';
echo '<label>' . 'ID:' . '</label>' . '<br />';
echo '<input class="input" type="text" name="id" value="'.$row1["id"].'" />';
echo '<br />';
echo '<label>' . 'User:' . '</label>' . '<br />';
echo '<input class="input" type="text" name="user" value="'.$row1["user"].'" />';
echo '<br />';
echo '<label>' . 'Active:' . '</label>' . '<br />';
echo '<input class="input" type="text" name="active" value="'.$row1["active"].'" />';
echo '<br />';
echo '<label>' . "Order:" . '</label>' . '<br />';
echo '<input class="input" type="text" name="orderid" value="'.$row1["orderid"].'" />';
echo '<br />';
echo '<label>' . 'Head:' . '</label>' . '<br />';
echo '<input class="input" type="text" name="head" value="'.$row1["head"].'" />';
echo '<br />';
echo '<label>' . "Address:" . '</label>' . '<br />';
echo '<textarea rows="15" cols="15" name="body">'.$row1["body"].'';
echo '</textarea>';
echo '<br />';
echo '<input class="submit" type="submit" name="submit" value="update" />';
echo '</form>';
}
}
if (isset($_GET['submit'])) {
echo '<div class="form" id="form3"><br><br><br><br><br><br>
<span>Data Updated Successfuly......!!</span></div>';
}
?>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</div><?php
mysql_close($connection);
?>
</body>
</html>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros