MySQL Update won't work [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

MySQL Update won't work [SOLVED]

Post by thiscatis »

I'm rather new to PHP, here is the PHP code :

Code: Select all

// We willen de ID van de pagina kennen.
if (isset($_GET['pid'])) {
     $pageid = preg_replace('/[^a-zA-Z0-9\_]/', '', $_GET['pid']);     // delete chars NOT in that set
} else {
     $pageid = 'page1';
} 

// We hebben de benodigde files nodig.
include('../../functions.php');
include('../../functions_willem.php');

// Naam user
$localuser = getcurrentuser(realpath('.'));

// We openen de verbinding met de database.
$db = opendatabase();
opendatabase();


// Update als nodig is.

if (isset($_POST['content_a'])) {

$content_a =  $_POST['content_a'];
$sqlquery =("UPDATE SET tblContent (content_a) VALUES ('$content_a') WHERE page='$pageid' AND username='$localuser' ");
$results = mysql_query($sqlquery);
 } 

else { };
and my HTML code :

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Update</title>
</head>
<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
  <br />
  <br />
  <textarea id="content_a" name="content_a" rows="15" cols="80"></textarea>
  <br />
  <input type="submit" name="save" value="Submit" />
  <input type="reset" name="reset" value="Reset" />
</form>
</body>
</html>
Why doesn't it work?

Connection to database = OK.
Last edited by thiscatis on Sat Jul 22, 2006 4:22 pm, edited 3 times in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Next time, please tell us exactly what is happening, simply don't say why isn't this working. Secondly you are checking for $POST['content_a'] -- this should be $_POST['content_a'].
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

Ok,

I've got it.

Code: Select all

if (isset($_POST['content_a'])) {

$content_a =  $_POST['content_a'];
$sqlquery =("UPDATE tblContent SET content_a='$content_a' WHERE page='$pageid' AND username='$localuser' ");
$results = mysql_query($sqlquery) or die(mysql_error()); 
 } 

else { };
works!
Post Reply