Storing/passing variables through multiple-part function/case statement

From: Date: Mon, 14 Oct 2002 20:31:03 +0000
Subject: Storing/passing variables through multiple-part function/case statement
Groups: php.general 
Request: Send a blank email to php-general+get-119950@lists.php.net to get a copy of this message
Hi, I¹m trying to cobble together a case where where data is retrieved from one row of a mySQL table, the row is deleted, the retrieved data is inserted into a new row in different table. Most of my code seems to be working (I think the data is being retrieved, the old row is being deleted, the new row is being created) but I am not getting a grip on how to pass the retrieved data into the sql insert statement for the new row in the second table. I¹m sure I¹m missing something very basic and would appreciate any help extended. The case statement as is now, is below. TIA, verdon Ps. Please cc me in any answer to the list as I am on digest mode case "finishPending": if ($user_dblocation) { @mysql_select_db("$user_dbname") or die ("Unable to select database"); $result = mysql_query("select uid, uname, name, url, email, femail, pass, company, bio, description, address, city, province, postcode, phone, fax, tollfree, otherphone, cat AS uid, uname, name, url, email, femail, pass, company, bio, description, address, city, province, postcode, phone, fax, tollfree, otherphone, cat from " . $table_prefix."users_que where uid='$approve_uid'"); list($uname) = mysql_fetch_row($result); mysql_query("lock tables " . $table_prefix."users_que WRITE"); mysql_query("delete from " . $table_prefix."users_que where uid='$approve_uid'"); mysql_query("unlock tables"); @mysql_select_db("$dbname") or die ("Unable to select database"); } else { $result = mysql_query("select uid, uname, name, url, email, femail, pass, company, bio, description, address, city, province, postcode, phone, fax, tollfree, otherphone, cat AS uid, uname, name, url, email, femail, pass, company, bio, description, address, city, province, postcode, phone, fax, tollfree, otherphone, cat from " . $table_prefix."users_que where uid='$approve_uid'"); list($uname) = mysql_fetch_row($result); mysql_query("lock tables " . $table_prefix."users_que WRITE"); mysql_query("delete from " . $table_prefix."users_que where uid='$approve_uid'"); mysql_query("unlock tables"); } mysql_query("LOCK TABLES " . $table_prefix."stories WRITE"); mysql_query("UPDATE " . $table_prefix."stories SET informant='$anonymous' WHERE informant='$uname'"); mysql_query("UPDATE " . $table_prefix."stories SET aid='$anonymous' WHERE aid='$uname'"); mysql_query("UNLOCK TABLES"); global $uid, $uname, $name, $url, $email, $femail, $pass, $company, $bio, $description, $address, $city, $province, $postcode, $phone, $fax, $tollfree, $otherphone, $cat; $sql = "insert into ".$table_prefix."users (name,uname,email,femail,url,pass,company,bio,description,address,city,provi nce,postcode,phone,fax,tollfree,otherphone,cat,conversionflag) values ('$name','$uname','$email','$femail','$url','$pass','$company','$bio','$desc ription','$address','$city','$province','$postcode','$phone','$fax','$tollfr ee','$otherphone','$cat','1')"; if ($user_dblocation) { @mysql_select_db("$user_dbname") or die ("Unable to select database"); mysql_query("lock tables " . $table_prefix."users WRITE"); $result = mysql_query($sql); mysql_query("unlock tables"); @mysql_select_db("$dbname") or die ("Unable to select database"); } else { mysql_query("lock tables " . $table_prefix."users WRITE"); $result = mysql_query($sql); mysql_query("unlock tables"); } if (!$result) { echo mysql_errno(). ": ".mysql_error(). "<br />"; return; } html_header_location("admin.php?op=adminMain"); echo mysql_error(); break;

« previous php.general (#119950) next »