Jump to content

[SOLVED] What's wrong with my code?


elmas156

Recommended Posts

Hey guys,

 

I'm having problems with this code and after several hours of going over it and trying different things I just can't seem to figure out what's wrong.  What I have is a link to this page and, using the GET method I make the users email and lp variables.  With this information I select several pieces of information from my database to set variables so that I can make those variables values in the form on this page... this way the user does not have to type in any of the information that isn't going to change because it's already there.  After the form is submitted, the new values are made into slightly different variables then updated in the database.  The problem is, they are not updating in the database.  I know the variables are being passed because I've tested them by echoing them onto the page.  Please let me know if you can see something that I'm overlooking.

 

Here's the code:

<?php
include("conf.inc.php"); // Includes the db and form info.
session_start(); // Starts the session.
$email=$_GET['email'];
$flp=$_GET['lp'];

$result = mysql_query("SELECT year,color,make,model,state,drive,engine,cylinders,oiltype,oilbrand,special,vehicleid FROM vehicles WHERE email = '$email' AND lp = '$flp'");
$row = mysql_fetch_row( $result );

$fyear = $row[0];
$fcolor = $row[1];
$fmake = $row[2];
$fmodel = $row[3];
$fstate = $row[4];
$fdrive = $row[5];
$fengine = $row[6];
$fcylinders = $row[7];
$foiltype = $row[8];
$foilbrand = $row[9];
$fspecial = $row[10];
$vehicleid = $row[11];

if (!isset($_POST['editvehicle'])) {

"Show the form"

} else {

$year = form($_POST['year']);
$color = form($_POST['color']);
$make = form($_POST['make']);
$model = form($_POST['model']);
$state = form($_POST['state']);
$lp = form($_POST['lp']);
$drive = form($_POST['drive']);
$engine = form($_POST['engine']);
$cylinders = form($_POST['cylinders']);
$oiltype = form($_POST['oiltype']);
$oilbrand = form($_POST['oilbrand']);
$special = form($_POST['special']);

mysql_query("UPDATE vehicles SET year = '$year',color = '$color' WHERE vehicleid = '$vehicleid'") or die (mysql_error());
header("Location: members.php");

}
?>

Link to comment
https://forums.phpfreaks.com/topic/122830-solved-whats-wrong-with-my-code/
Share on other sites

$vehicleid is set at the top of the page when all the initial variables are set:

 

$vehicleid = $row[11];

 

As far as I know it shouldn't change from it initial value but I'll play with it some more and see what I can do.  Thanks for your input.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.