Forum Moderators: coopster

Message Too Old, No Replies

Help retrieving data from a URL!

retrieving data from a URL using $_GET

         

cjorson

3:19 pm on Feb 3, 2003 (gmt 0)

10+ Year Member



Hi,

I am hoping that someone may be able to help me as I am at a loss!

I am trying to retrieve data from a URL and then pass this data into a database. I am using php 4.2 and apache 1.3 on a windows XP platform (hope that covers everything!)

The problem is that I can retrieve most of the information from the URL using the $_GET['data']; command, however for some reason this command will not work on the final two variables in the URL. I have included my code below:

<?php
$tCost = $GET_['totalCost'];
$tPrice = $GET_['totalPrice'];
$id = $_GET['id'];
$group = $_GET['group'];
$modId = $_GET['modId'];
$varId = $_GET['varId'];
$trimId = $_GET['trimId'];
$engId = $_GET['engId'];
$colId = $_GET['colId'];
$packOne = $_POST['packOne'];
$packTwo = $_POST['packTwo'];
$packThree = $_POST['packThree'];

?>

<table width=100% cellpadding =10>
<tr bgcolor=#ffffff align=middle>
<td align=middle cellpadding=2 bgcolor=#006699><span class="heading"> <font color=#ffffff>Add new vehicle</font> </span>
</td>
</tr>
<?php

$sql = "INSERT INTO cars (model, der, variant, engine, colour) VALUES ('$modId', '$varId', '$trimId', '$engId', '$colId')";

$added = mysql_query($sql);

print $GET_['totalCost'];
print $tPrice;
print $modId;
print $sql;

?>

The two variables that it won't pick up are totalCost and totalPrice. The URL that I am passing is:

added.php?modId=1&varId=1&trimId=1&engId=1&colId=1&pack1=1&pack2=2&pack3=3&totalCost=5650&totalPrice=8700

it will pick up all of the other variables from the URL except those two, and I am quite confused about it!

If anybody can shed any light on this it would be much appreciated - I suspect I am missing something obvious here :)

Thanks in advance,

Chris

Nick_W

3:25 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried using the parse_url() function [php.net]?

Nick

dingman

6:15 pm on Feb 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem in that code snippet looks to me like a simple misplaced '_'.

$tCost = $GET_['totalCost'];
$tPrice = $GET_['totalPrice'];

should be

$tCost = $_GET['totalCost'];
$tPrice = $_GET['totalPrice'];

cjorson

6:35 pm on Feb 3, 2003 (gmt 0)

10+ Year Member



oh thank you very much!

I had been staring at it for hours, and couldn't see anything wrong at all... sometimes it takes a fresh pair of eyes.

My sanity is now restored, thanks very much!