| | |
Problem with $_GET variables...
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2007
Posts: 45
Reputation:
Solved Threads: 1
I am writing a script to add and edit listings in a realestate site.
For some reason I can't get the variables from the url to recognize properly.
heres the "problem" part of the script:
the url that calls this is:
heres is the first part of "imgup.php"
(If you wonder why I set editid equal to zero, its so that if I need to check later on in this page if editid is set, I just check if its set to 0 instead of using isset...I know its really no big deal, Its just an attempt to keep it easy to read when i look back at it some time later)
headerurl echos as: "id=#" (obvious # represents an actual number, in this case, the number of the "temp id", which I verified to be accurate)
Seems to work fine when I "add a new listing", but when I edit one, thats when the problem appears.
all i can say is -- what the..? What am I missing??
For some reason I can't get the variables from the url to recognize properly.
heres the "problem" part of the script:
PHP Syntax (Toggle Plain Text)
<?php require_once "../dbconnect.php"; // include the database information // if the 'mode' is set in the url (i.e. is the originating call is from new (mode is not set from this file) or edit ) if (isset($mode)) { // get the id of the row to be editted from the url $editid = $_GET['id']; //retrieve the old pictures field and place into temp $old = mysql_query("SELECT * FROM commercial WHERE id = ".$editid); $rowold = mysql_fetch_assoc($old); $pictures = $rowold['pictures']; mysql_query("INSERT INTO temp (id, pictures) VALUES (NULL, '$pictures' )") or die("somthing went wrong during the registration. MySQL said: ".mysql_error()); $result = mysql_query("SELECT * FROM temp"); $row = mysql_fetch_assoc($result); // get the temp id $id = $row['id']; $url = "imgup.php?id=".$id."&editid=".$editid; } else { // if temp is not already in use, i.e., pictures not already added, then create temp mysql_query("INSERT INTO temp (id, pictures) VALUES (NULL, '' )") or die("somthing went wrong during the registration. MySQL said: ".mysql_error()); $result = mysql_query("SELECT * FROM temp"); $row = mysql_fetch_assoc($result); $id = $row['id']; $url = "imgup.php?id=".$id; } // redirect to upload images script echo("<script> <!-- location.replace(\"".$url."\"); --> </script>");?>
the url that calls this is:
PHP Syntax (Toggle Plain Text)
images.php?id=27&mode=edit
heres is the first part of "imgup.php"
PHP Syntax (Toggle Plain Text)
<?php $id = $_GET['id']; if (isset($_GET['editid'])){ $editid = $_GET['editid']; $headerurl = "?id=".$id."&editid=".$editid; } else { $headerurl = "?id=".$id; $editid = "0"; } echo $headerurl; . . .
(If you wonder why I set editid equal to zero, its so that if I need to check later on in this page if editid is set, I just check if its set to 0 instead of using isset...I know its really no big deal, Its just an attempt to keep it easy to read when i look back at it some time later)
headerurl echos as: "id=#" (obvious # represents an actual number, in this case, the number of the "temp id", which I verified to be accurate)
Seems to work fine when I "add a new listing", but when I edit one, thats when the problem appears.
all i can say is -- what the..? What am I missing??
•
•
Join Date: Oct 2009
Posts: 15
Reputation:
Solved Threads: 3
0
#2 31 Days Ago
PHP Syntax (Toggle Plain Text)
<?php require_once "../dbconnect.php"; // include the database information // if the 'mode' is set in the url (i.e. is the originating call is from new (mode is not set from this file) or edit ) if (isset($mode)) { // get the id of the row to be editted from the url $editid = $_REQUEST['id']; //retrieve the old pictures field and place into temp $old = mysql_query("SELECT * FROM commercial WHERE id = ".$editid); $rowold = mysql_fetch_assoc($old); $pictures = $rowold['pictures']; mysql_query("INSERT INTO temp (id, pictures) VALUES (NULL, '$pictures' )") or die("somthing went wrong during the registration. MySQL said: ".mysql_error()); $result = mysql_query("SELECT * FROM temp"); $row = mysql_fetch_assoc($result); // get the temp id $id = $row['id']; $url = "imgup.php?id=".$id."&editid=".$editid; } else { // if temp is not already in use, i.e., pictures not already added, then create temp mysql_query("INSERT INTO temp (id, pictures) VALUES (NULL, '' )") or die("somthing went wrong during the registration. MySQL said: ".mysql_error()); $result = mysql_query("SELECT * FROM temp"); $row = mysql_fetch_assoc($result); $id = $row['id']; $url = "imgup.php?id=".$id; } // redirect to upload images script echo("<script> <!-- location.replace(\"".$url."\"); --> </script>");?>
PHP Syntax (Toggle Plain Text)
<?php $id = $_REQUEST['id']; if (isset($_REQUEST['editid'])){ $editid = $_REQUEST['editid']; $headerurl = "?id=".$id."&editid=".$editid; } else { $headerurl = "?id=".$id; $editid = "0"; } echo $headerurl; . . .
0
#4 31 Days Ago
Use either GET or POST. Don't use REQUEST as it has security flaws.
Google is your friend.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
![]() |
Similar Threads
- Problem with external variables in Actionscript 3 (Graphics and Multimedia)
- Problem with $_GET[] (PHP)
- Problem with xsl variables (XML, XSLT and XPATH)
- Problem passing variables to thread (Perl)
- problem with select statement filter thru GET url... (PHP)
- sending variables to other pages (PHP)
- Problem with $_GET variable (PHP)
- Problem with php5 variables (PHP)
Other Threads in the PHP Forum
- Previous Thread: how to pass variable between pages, without form???
- Next Thread: Reister form won't work
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






