mikebyrne Posted November 30, 2007 Share Posted November 30, 2007 I would like my code to delete the relevant confirm_code from the temp_users table but I'm getting the error Your account has been activatedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE confirm_code = '5f6feb0f5d104c2a6b7ce24d40711f74'' at line 1 My code is <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $sql1 = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($sql1) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql2="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql2)or die(mysql_error()); echo "Your account has been activated"; $sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$passkey'"; $result2=mysql_query($sql3)or die(mysql_error()); } } ?> Quote Link to comment Share on other sites More sharing options...
Demont Posted November 30, 2007 Share Posted November 30, 2007 Try //If cmd has not been initialized if(!isset($cmd)) { //display all passkeys $result = mysql_query("select * from tbl_name1 order by passkey"); echo "<table border='1'> <tr> <th>Key</th> <th>User</th> </tr>"; while($r=mysql_fetch_array($result)) { //grab the title and the ID of the news $title=$r["user"];//take out the title $id=$r["key"];//take out the id //make the title a link echo "<td>" .$r['key']. "</td>"; echo "<td><a href='delete.php?cmd=delete&id=$id'>".$r['user']." - Delete</a></td>"; echo "</tr>"; } } if($_GET["cmd"]=="delete") { $sql = "DELETE FROM tbl_name1 WHERE id=$passkey"; $result = mysql_query($sql); echo "Deleted! <a href='delete.php'>Go back</a>"; } ?> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted November 30, 2007 Author Share Posted November 30, 2007 could i not just insert an sql Delete my code? Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted November 30, 2007 Author Share Posted November 30, 2007 This solved my problem <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $sql1 = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($sql1) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql2="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql2)or die(mysql_error()); echo "Your account has been activated"; $sql3="DELETE FROM $tbl_name WHERE confirm_code = '$passkey'"; $result3=mysql_query($sql3)or die(mysql_error()); } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.