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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.