Jump to content

Archived

This topic is now archived and is closed to further replies.

txrandom

Trouble with an activation script

Recommended Posts

In my script, the user enters his activation code. If the activation code matches the one found in the database, the users data associated with that activation code is selected from the unactivated user table and added to the activated user table.  My script also deletes activation codes that have already been used.  My only problem is that my script will not delete the row in the unactivated user table.

[code]<?php
include "config.php";

$activation = $_GET['id'];

$query="SELECT * FROM uauser WHERE activation='$activation'";
$result=mysql_query($query);
$num=mysql_num_rows($result);

if ($num > 0 ) {

$row = mysql_fetch_assoc ($result);
$user = $row['user'];
$password = $row['password'];
$realname = $row['realname'];
$email = $row['email'];
$joineddate = $row['joindeddate'];

mysql_query("DELETE FROM 'uauser' WHERE activation='$activation' LIMIT 1");

$query = "INSERT INTO user (user, password, realname, email, joineddate)
VALUES('".$user."','".$password."','".$realname."','".$email."','".$joineddate."')";
$result = mysql_query($query);

echo "Activation successful!";
} else {
echo "Activation unsuccessful.  Your activation code wasn't found.";
}
?>
[/code]

Help is much appreciated.  The deletion codes perfectly in a script that just deletes stuff.  I think since I queried the database before I tried deleting stuff, it is getting messed up.

Share this post


Link to post
Share on other sites
I just tried it by itself and it didn't work either.  An exact script but with different table and field names works fine on another part of my site.

[code]<?php
include "config.php";
$activation = $_GET['id'];

mysql_query("DELETE FROM 'uauser' WHERE

activation='$activation'") or die();

echo "must of worked";

?>
[/code]

No one has any idea what I'm doing wrong?

Share this post


Link to post
Share on other sites
Could this problem have something to do with my MySQL accounts permissions? I'm going to test this script on my other server and see if it works.  If it does, I think it's a permissions issue.  How do I change an accounts permissions? I lost the walkthrough I use to have.

Share this post


Link to post
Share on other sites
Well, I found a different way to do a user activation.  But I'm still curious as to why I can't delete it!

Share this post


Link to post
Share on other sites
Hmm.. Why not just change it to 0 = unactivated and 1 = activated ?

Share this post


Link to post
Share on other sites
Yah, I ended up doing that.  I'm just hoping this problem won't bug me when I absolutely have to be able to delete a row.

Share this post


Link to post
Share on other sites
Example of deleting..
[code]mysql_query("DELETE FROM `left` WHERE `key` = '$key' LIMIT 1") or die (mysql_error());[/code]

Share this post


Link to post
Share on other sites

×

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.