473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Why doesnt $_GET ['$example'] Work?

hi
dont really know how to explain it so i'll just show the code

what i need it to do is
$_get information from the url that is stored in a variable
for example
abc=1,bcd=2

(load abc and bcd in a while loop from database)
set $name=$_get[$variable]
display the name then wipe before movin on to the next variable in the database


this is where the information is sent
Expand|Select|Wrap|Line Numbers
  1. while($row = mysql_fetch_array($result)) {
  2. $ddriver=$row['driver'];
  3. echo"<br> Enter $ddriver 's Hours For $date <input type='text' name='$ddriver' value='0' size='5'>";
  4. };
  5. echo"<br><input type='submit' value='Generate Preview Profit Loss Sheet For $date'></form>";
  6.  
and this is the section where its supposed pick it up

Expand|Select|Wrap|Line Numbers
  1. $query="SELECT * FROM `drlist`";
  2. $result=mysql_query($query);
  3. while($row = mysql_fetch_array($result)) {
  4. $dname=$row['dname'];
  5. $dhourrate=$row['dhourrate'];
  6. $ddriver=$_GET [$dname];
  7. echo "$dname,$ddriver, test ,$dhourrate";
  8. if ($ddriver<>'') {
  9. $driverwork=$ddriver-0.75;
  10. $drivercost=$driverwork*$dhourrate;
  11.  
  12. echo " Driver $dname, Hours After Break = $driverwork, Driver Cost @ $dhourrate per hour =                 
  13. $drivercost";}; 
  14. $ddriver='';
  15. };
  16.  
  17.  
  18. };
  19.  
i know this method isnt very secure but at the moment i just need this working can anyone help
Jan 7 '10 #1
3 2449
dlite922
1,584 Expert 1GB
$_GET [$dname]; <--- Why is there a space between $_GET and [$dname] ?

Also, you didn't tell us where the code breaks, What's the error you get if any. Is error_reporting turned on?



Dan
Jan 7 '10 #2
sorry that was just a typo there is no space in the code as for code breaks, i dont get any errors with reporting on, the rest of the page loads fine ive used echos to display all the variables after loading however the $_GET[$dname]; is the only one it doesnt retrieve is there a different way of formating the [$dname]; or something due to it being a variable not a set name?
Jan 8 '10 #3
Markus
6,050 Expert 4TB
Check the validity of your claim that $_GET[$dname] exists.

Expand|Select|Wrap|Line Numbers
  1. if (!isset($_GET[$dname])) {
  2.      printf("%s does not exist in the URL (%s",
  3.              $dname, $_SERVER['QUERY_STRING']);
  4. }
  5.  
If you receive the printed error, then you know you are doing something wrong.

Also post the results of that test.

Mark.
Jan 8 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

32
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at...
0
by: Eclectic | last post by:
I am using the latest version of PHP and GD (reinstalled both today - march 29 2005) and am using GD to create thumbnails on the fly. I am having no issues with GD, however, I am now trying to...
27
by: meltedown | last post by:
urlencode turns # into %23 When I sent it thru $_GET, it dissapears, along with anything that comes after it. for example: urlencode turns HOYDM_EXC_#4_NAT into HOYDM_EXC_%234_NAT When I...
3
by: stephane | last post by:
I have a file.php in which a created dynamic hypertext links and send a variable $row echo "<td><a href='modify_request.php?$row'>$row</a></td>"; I can see in the url on modify_request.php the...
8
by: dude | last post by:
i'll try to be short ... i have this in html : <select name="OS" size="5"> <option value="0" selected>Please select one or more...</option> <option value="1">Windows</option> <option...
9
by: wouter | last post by:
hey hi..... I wanna make a switch wich does this: if pagid is set do A, if catid is set do B, if projectid is set do C, else do D. So i was thinking something like this:
5
by: Gunnar G | last post by:
Hi. If I execute a php script with exec exec("foo.php"); and foo.php reads the $_GET array (can't change that I must work with $_GET), how can I set values to $_GET array? Can I do it directly in...
4
by: Sen | last post by:
Hi, why: $n = count($_GET); for($i=0; $i<$n; $i++) { echo $_GET }
8
by: The KwikOne | last post by:
Since to have a page validate (HTML and XHTML) you should have your URL parameters separated by the appropriate separator. However, if an ampersand is used it needs to be expressed as &amp; (example:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.