Results 1 to 5 of 5
  1. #1
    Join Date
    March 20th, 2005
    Need Help Updating Data
    Howdy Folks,
    First time here, but I gotta problem I can't see. I am new to php so I may not be the most efficient. I have written two files to modify a database, first file allows you to enter a vin# it then looks up that number and populates a form with the fields of that record. You can then go in and change the fields that you want modified. I have it on submit launch the update.php file, I also have a form in here to make sure the updated data is moved over. I then want to run a query to update the database with the new fields, but it wont. I have included the problem script below. I have been playing with it so there is a lot of things that dont need to be there. but it is how I debug.

    thanks for your help.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <!-- Created with the CoffeeCup HTML Editor 2005 -->
    <!-- -->
    <!-- Brewed on 3/19/2005 1:17:24 PM -->


    $vin =$_POST['oldvin'];
    $newvin = $_POST['newvin'];
    $newyear = $_POST['newyear'];
    $newmake = $_POST['newmake'];
    $newmodel = $_POST['newmodel'];
    $newmileage = $_POST['newmileage'];
    $newtransmission = $_POST['newtransmission'];
    $newprice = $_POST['newprice'];
    $newengine = $_POST['newengine'];
    $newcomments = $_POST['newcomments'];
    $newbody_style = $_POST['newbody_style'];
    $newext_color = $_POST['newext_color'];
    $newint_color = $_POST['newint_color'];
    $newdrive_type = $_POST['newdrive_type'];
    $newfuel_type = $_POST['newfuel_type'];
    $newdoors = $_POST['newdoors'];

    echo "<form method='POST' action='update.php'>";
    echo "Vin #: <input type='text' value='$newvin' size='17' maxlength='17'/>"."<br />";
    echo "Year: <input type='text' value='$newyear' size='17' maxlength='17'/>"."<br />";
    echo "Make: <input type='text' value='$newmake' size='17' maxlength='17'/>"."<br />";
    echo "Model: <input type='text' value='$newmodel' size='17' maxlength='17'/>"."<br />";
    echo "Price: <input type='text' value='$newprice' size='17' maxlength='17'/>"."<br />";
    echo "Mileage: <input type='text' value='$newmileage' size='17' maxlength='17'/>"."<br />";
    echo "Body Style: <input type='text' value='$newbody_style' size='17' maxlength='17'/>"."<br />";
    echo "Transmission Type: <input type='text' value='$newtransmission' size='17' maxlength='17'/>"."<br />";
    echo "Engine Size: <input type='text' value='$newengine' size='17' maxlength='17'/>"."<br />";
    echo "Exterior Color: <input type='text' value='$newext_color' size='17' maxlength='17'/>"."<br />";
    echo "Interior Color: <input type='text' value='$newint_color' size='17' maxlength='17'/>"."<br />";
    echo "Drive Type: <input type='text' value='$newdrive_type' size='17' maxlength='17'/>"."<br />";
    echo "Type of Fuel: <input type='text' value='$newfuel_type' size='17' maxlength='17'/>"."<br />";
    echo "#of Doors <input type='text' value='$newdoors' size='17' maxlength='17'/>"."<br />";
    echo "Comments: <input type='text' value='$newcomments' size='50' maxlength='255'/>"."<br />";
    echo "<input type='submit'name='submit'>";
    echo "</form>";

    $sql="UPDATE inventory SET vin='$newvin',year='$newyear',make='$newmake', model='$newmodel',price ='$newprice',mileage='$newmileage',body_style='$newbody_style', transmission='$newtransmission',engine='$newengine',ext_color='$newext_color',int_color='$newint_color',drive-type='$newdrive_type',fuel_type='$newfuel_type',doors=$newdoors, comments=$newcomments WHERE vin=$vin";

    echo "$sql"."<br />";
    $result = mysql_query($sql);
    if (mysql_affected_rows() == 1) {
    echo "Updated Successfully!";
    require ('');
    echo "the result key= ".$result."<br />";
    echo "Update Failed!!!";


  2. #2
    The Great Egress NewcastleB's Avatar
    Join Date
    January 19th, 2005
    I just took a quick look at your query string. Several places seem to have spaces that shouldn’t be there. Like ‘do ors’ and ‘$ne wbody_style’. That may not be in your code just in the way it displays here, I’m not sure. You also seem to have missed some single quotes. Look at do ors=$newdoors, comments=$newcomments .
    But are you still master of your domain?

  3. #3
    Join Date
    March 20th, 2005
    it is not like that in my code, i just didnt proof read it when i copied. do you need to put ' ' around a variable in an update query?

  4. #4
    The Great Egress NewcastleB's Avatar
    Join Date
    January 19th, 2005
    If the variable is a string, you need to enclose it in quotes. Without the quotes, MYSQL might be able to figure out where the string starts (after the =), but how would it know where the string ends. Remember that what MYSQL sees is what you see when you echo $sql. I think that I use too many quotes, like around numbers, but it seems to work and I don’t run into problems where I forget to put quotes around something I have to.
    But are you still master of your domain?

  5. #5
    Join Date
    March 20th, 2005
    got it
    i had a - where a _ should have been, looks like i missed a shift.
    I ran it through the mysql monitor and it pointed right to it.
    give it a try on problem queries.

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Data Feed Not Updating
    By Cheesehead in forum Programming / Datafeeds / Tools
    Replies: 4
    Last Post: April 2nd, 2006, 12:19 AM
  2. Data feed not updating
    By Asif in forum Commission Junction - CJ
    Replies: 7
    Last Post: November 24th, 2004, 05:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts