Jump to content

Recommended Posts

Hi Guys,

 

for some reason this code is not working, i dont suppose anyone can spot an obvious error?

 

many thanks in advance.

 

<?php

// Check if session is not registered , redirect back to login page.

include('../includes/checklogin.php');

// Connect to server and select database

include('../db_login.php');

 

$oldusername = $_GET['username'];

 

// username and password sent from form

$username =$_POST['username'];

$password =md5($_POST['password']);

 

// Insert data into mysql

$query = "UPDATE tusers

          SET username = '$username' ,

          password = '$password'

          WHERE username = '$oldusername'";

         

$result = mysql_query($query);

 

// if successfully insert data into database, displays message "Successful".

  if($result){

  echo "Successful";

  echo "<BR>";

  echo "<a href='administration.php'>Back to admin</a>";

  }

  else {

  echo "ERROR  <BR>";

  // for testing

  echo "old $oldusername <BR>";

  echo "new $username <BR>";

  echo "pass $password <BR>";

  }

?>

 

my echo's for testing display the correct information but will not update the data in the database!!! :(

Link to comment
https://forums.phpfreaks.com/topic/82956-solved-update-statement-problem/
Share on other sites

Great news that you fixed it but for future issues have a look what i posted just after you had replyed.

 

 

change

 

$result = mysql_query($query);

 

to

 

$result = mysql_query($query) or die('Error updating: '.mysql_error());

 

That will return what error you have.

 

The syntax looks fine but could be a column name or somthing.

 

This is a very very useful debugging code to use!

 

Regards

Liam

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.