home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

PHP Help - Delete row

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1710
Discussions: 200,933, Posts: 2,379,196, Members: 246,298
Old August 7th, 2006, 10:24 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Join Date: Jul 2003
Posts: 1,253
PHP Help - Delete row

I have a script that checks a databases, saves the information as variables temporarily, deletes the old row, and then creates a new row in a different table. The problem is that I can't the old row to delete itself. I've tested it on two machines, I have no idea why I can't get delete stuff. My priveleges are fine.

PHP Code:
<?php
include "config.php";

$activation $_GET['id'];

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

if (
$num ) {

$row mysql_fetch_assoc ($result);
$user $row['user'];
$password $row['password'];
$realname $row['realname'];
$email $row['email'];
$joineddate $row['joindeddate'];
mysql_close();
include 
"config.php";

mysql_query("DELETE FROM 'unactivated' WHERE activation='$activation'");

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

echo 
"Activation successful!";
echo 
"$activation";
} else {
echo 
"Activation unsuccessful.  Your activation code wasn't found.";
}
?>
Rand Dusing is offline   Reply With Quote
Old August 8th, 2006, 10:18 AM     #2 (permalink)
Member
 
drizzle's Avatar
 
Join Date: Oct 2001
Location: Louisiana, USA
Posts: 256
Send a message via MSN to drizzle
Any reason why you're including config.php twice - the second time after closing the database connection? If this is within the same database it isn't needed twice. Try this code below and see what happens. It should give you an error why the query is failing.
PHP Code:
<?php
include "config.php";

$activation $_GET['id'];

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

if (
$num ) {

$row mysql_fetch_assoc ($result);
$user $row['user'];
$password $row['password'];
$realname $row['realname'];
$email $row['email'];
$joineddate $row['joindeddate'];
//mysql_close();
//include "config.php";
//
// Modified this line here...
$query mysql_query("DELETE FROM unactivated WHERE activation='$activation'") or die('Query failed: ' mysql_error());

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

echo 
"Activation successful!";
echo 
"$activation";
} else {
echo 
"Activation unsuccessful.  Your activation code wasn't found.";
}
?>
drizzle is offline   Reply With Quote
Old August 8th, 2006, 01:56 PM     #3 (permalink)
Ultimate Member
 
Join Date: Jul 2003
Posts: 1,253
I orignally had it without the mysql_close(); and include "config.php", I put them in to try to find the problem. I put the Query failed and mysql_error(); and now it magically works.

Thanks, PHP/MySQL has been acting strange for me lately.
Rand Dusing is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
shading every other row in Excel ShuckyD Applications and Operating Systems 0 July 26th, 2006 10:11 AM
Row height differences in IE and FF Super Nick Webmastering and Programming 1 July 18th, 2006 02:38 PM
Two bad 6600GT's in a row??? DanU Graphics Cards and Displays 5 February 13th, 2006 11:14 PM
Double-Row RAM? Kc2iLq General Tech Discussion 8 February 6th, 2003 10:11 PM
Where does Win2KPro delete profile folders when you delete them from System Cntrol Pa Wolf23 Applications and Operating Systems 8 September 27th, 2002 12:19 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2887)
Wireless Televisions. (5)
California Passes Anti-Flat-HDTV Le.. (39)
Obama the Muslim (14)
Is the PSU I received dead? (10)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
HIS HD5770 graphic card question (15)
Print spooler problem (13)
Foreign voltage (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
EVGA 9800 gtx help with finding a g.. (8)
New Computer wont recognize XP disc (7)
Recent Discussions
Wireless Televisions. (5)
CPU fan stops spinning randomly (2)
World's largest Monopoly Game using G.. (332)
Ideal cheap graph card for PC-Gaming? (17)
BIOS won't read disk when I try to fl.. (0)
Install XP pro and a Vista laptop ?? (11)
Partition Magic caused HDD problem (2)
Graphics Card Upgrade Question (1)
favorit (1)
solutions for virtical white lines on.. (1)
Regular Build (3)
Fire in DVD (2)
Modern Warfare For the PC (33)
radeon x850xt platinum & shader 3 (3)
Have you switched yet? (84)
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)


All times are GMT -4. The time now is 10:01 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28