Ninjakreborn Posted July 10, 2006 Share Posted July 10, 2006 I am trying to pass a db variable from one script to the next but nothing is working.Admin page[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Approval</title></head><body><h3>Welcome Bobby</h3><p>These are recently pending database entries, please accept/decline. Please note declined entries are automatically permanently deleted from the database. These are all updated together, upon submit. The ones that are approved are set to approved status, the ones that are declined, are immediately deleted from the database, and the file is removed from it's location on the server. If you check some of the choice, and leave some of the choice alone, they will still be here later, for instance if there are 3 items listed. If you approve 1, decline 1, and leave the other alone for now, the approved one is updated, the declined one is deleted, and the one left alone, is not touched, and left there, for you to update later.</p><?php // Connects to database$connect = mysql_connect("localhost", "#####", "#####");$select = mysql_select_db("funnyemailforwards");$errorhandler = "";$management = true;if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false;}?> <?php // script to display information$result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC");echo "<form name=\"dataupdating\" action=\"approvalprocessor.php\" method=\"post\">";while ($row = mysql_fetch_assoc($result)){extract($row);$date = date("m/d/y");$website = "http://www.funnyemailforwards.com/apex/";$site = $website . $funnyurl; echo "<ul>"; echo "<li><a href=" . '"' . $site . '"' . 'target="_blank">' . $nameoffunny . "</a></li>"; echo "<li>" . $date . "</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>"; echo "</ul>"; $manager = true;}if ($manager === true) {echo "<input name=\"funny\" type=\"hidden\" value=\"{$funnyurl}\" />";echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">";echo "</form>";}?></body></html>[/code]Here is my processor page[code]<?php // Connects to database$connect = mysql_connect("localhost", "#####", "#####");$select = mysql_select_db("funnyemailforwards");$errorhandler = "";$management = true;if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false;}?> <?phpif (isset($_POST['update'])) { foreach ($_POST['approval'] as $key => $value) { if ($value) { mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key); echo "Update Successful, update"; } else { mysql_query('DELETE FROM fileinfo WHERE id='.$key); echo "Update Successful, delete from db"; echo "{$funnyurl}"; unlink($funnyurl); // url is set to exactly like this // http://www.funnyemailforwards.com/apex/uploads/filename.ext // Follows a path exactly to the file. } }// closes foreach}// closes isset control structure?>[/code]I am having a few issues, I am trying to pass the variable $funnyurl over to the other page. I originally thought it did it automatically, but I soon realized I have to use hidden form fields or something similar.I understand that, but not's why it'sn ot passing the variable even through hidden form field.THe variable is being pulled from the db, with the use of the extract function. As well the variable has been tested, and it works, the approval pages, displays information using the $funnyurl variable,In the db the $funnyurl is set to uploads/filename.extThis allows for the quick part of the file, in my scripts, I have another variable$site = "http://www.funnyemailforwards.com/apex";Which is the direcotrythen I put$url = $site . $funnyurlAnd I get a successful combination leading directly to the file, this works so far in all my script, but I tried doing this entire script on one page, I am still fairly new to php, so my [b]main[/b] weakpoint is doing same page scripts. If I have 5 scripts doing the same thing, or a form, I can never get it to work on same page, I haven't gotten there yet, but even now I am having trouble, I don't get it, any advice, I tried passing it normally, but variables don't pass like that, then I tried the hidden form field, the same with connections, I thought if you connected to a db, it stayed open in between scripts, but I had to reopen the connection on the other page as well. IS there a reason the variable isn't getting read, or do I have to use a whole nothing db call for it to have access to the variable information, I thought variable information was passed through the form field. Or is the other page not accessing the db for the information, if that is true, can't I just put my db connection, database seclecting, information retrieval, and extract function in a seperate page, and include them in all of them so all my scripts have the same access, or is this another issue? Quote Link to comment https://forums.phpfreaks.com/topic/14176-difficulties-passing-variables/ Share on other sites More sharing options...
Ninjakreborn Posted July 10, 2006 Author Share Posted July 10, 2006 bump Quote Link to comment https://forums.phpfreaks.com/topic/14176-difficulties-passing-variables/#findComment-55571 Share on other sites More sharing options...
wildteen88 Posted July 10, 2006 Share Posted July 10, 2006 Try $_POST['funnyurl'] instead of $funnyurl in your processor script.Also dont bump your threads until they are atleast 2 or more hours old. Quote Link to comment https://forums.phpfreaks.com/topic/14176-difficulties-passing-variables/#findComment-55582 Share on other sites More sharing options...
Ninjakreborn Posted July 10, 2006 Author Share Posted July 10, 2006 Sounds good, I just ran the connect, and select statement, and extract in a include, and included it in both, so I can freely use variables in both scripts from the database. Quote Link to comment https://forums.phpfreaks.com/topic/14176-difficulties-passing-variables/#findComment-55594 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.