php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43937 Script will not move row from 1 table to another. Works w/ PHP4.
Submitted: 2008-01-25 16:37 UTC Modified: 2008-01-28 22:56 UTC
From: Admin at hellzoneinc dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.2.5 OS: Server 2008
Private report: No CVE-ID: None
 [2008-01-25 16:37 UTC] Admin at hellzoneinc dot com
Description:
------------
Well, I am using php-nuke for my website. I've had issues w/ PHP5 before and have always gone back to PHP4 since it worked. Since the new release isn't psoted for Windows yet, I must use PHP5. Everything works fine with the user registration EXCEPT.... When the user clicks the activate link in their e-mail, it brings them to the page saying it was successful, but it's wrong. The user info gets entered into the nuke_users_temp table just fine, however when the activate script runs, it doesn't copy the info over to nuke_users as it should, but does make it through to the remove that row. PHP4 works fine with this so I figured it's a PHP5 issue, so hope this helps.

Reproduce code:
---------------
It's not a visual error, so here goes. Sorry for the numerous lines.

function activate($username, $check_num) {
	global $db, $user_prefix, $module_name, $language, $prefix;
	$username = filter($username, "nohtml", 1);
	$past = time()-86400;
	$db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE time < $past");
	$sql = "SELECT * FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'";
	$result = $db->sql_query($sql);
	if ($db->sql_numrows($result) == 1) {
		$row = $db->sql_fetchrow($result);
		$user_password = htmlspecialchars(stripslashes($row['user_password']));
		if ($check_num == $row['check_num']) {
			$db->sql_query("INSERT INTO ".$user_prefix."_users (user_id, username, user_email, user_password, user_avatar, user_avatar_type, user_regdate, user_lang) VALUES (NULL, '".$row['username']."', '".$row['user_email']."', '$user_password', 'gallery/blank.gif', '3', '".$row['user_regdate']."', '$language')");
			$result2 = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='".$row['username']."'");
			$row2 = $db->sql_fetchrow($result2);
			$guserid = intval($row2['user_id']);
                        $db->sql_query("INSERT INTO ".$prefix."_bbgroups (group_name, group_description, group_single_user, group_moderator) VALUES ('', 'Personal User', '1', '0')");
                        $group_id = $db->sql_nextid();
                        $db->sql_query("INSERT INTO ".$prefix."_bbuser_group (user_id, group_id, user_pending) VALUES ('$guserid', '$group_id', '0')");
			$db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'");
			include("header.php");
			title(""._ACTIVATIONYES."");
			OpenTable();
			echo "<center><b>".$row['username'].":</b> "._ACTMSG."</center>";
			CloseTable();
			include("footer.php");
			die();
		} else {
			include("header.php");
			title(""._ACTIVATIONERROR."");
			OpenTable();
			echo "<center>"._ACTERROR1."</center>";
			CloseTable();
			include("footer.php");
			die();
		}
	} else {
		include("header.php");
		title(""._ACTIVATIONERROR."");
		OpenTable();
		echo "<center>"._ACTERROR2."</center>";
		CloseTable();
		include("footer.php");
		die();
	}

}

Expected result:
----------------
Copy the user from nuke_users_temp to nuke_users and I believe maybe 2 other tables from what I think I'm seeing, then remove that line from nuke_users_temp.

Actual result:
--------------
Does not copy the user, but then removes them from nuke_users_temp as it should.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-25 17:23 UTC] php at zjs dot name
Looking at the code, it appears it's a problem with the code, not a bug in php (although it's hard to be 100% sure because that piece of code makes references to several others). If you could provide a more straight-forward test case, it would make it much easier to investigate, but because it doesn't look like a bug, I'd suggest looking for help  from one of the places listed on http://www.php.net/support.php or from php-nuke as it appears the issue is on their end.
 [2008-01-25 19:16 UTC] Admin at hellzoneinc dot com
I guess the reason I feel it is a PHP5 issue is because this works perfectly w/ PHP4, and all forums online say downgrade back to it, which if the Windows Binaries were listed, I would. Why would this then work just find on PHP4, but not PHP5?
 [2008-01-25 21:06 UTC] phpbugs at mailinator dot com
I think php at zjs dot name hit the answer on the nose. This isn't a php issue.
I suggest taking a look at the number of things that have changed between versions (http://www.php.net/ChangeLog-5.php, http://www.php.net/ChangeLog-4.php) and then taking a look at the quality of the code. The issue is with the code, not php.
An example of what I'm talking about: Instead of verifying that the database changes did in fact work (an easy thing to do), it assumes they did, and displays a message to that effect.  

What I think you're options are (in the order I'd recommend them):
 1 - upgrade to a version of php-nuke that supports php5
 2 - debug the code
 3 - downgrade to php4 (support has been discontinued, but the source is available at http://www.php.net/downloads.php)
 [2008-01-28 22:56 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 19:01:30 2024 UTC