SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    wont update after first field

    editcv.php

    Hi guys, this is strange. This is my update script the first field "name" updates but all the others stay the same

    Can anyone see why?



    <form action="updated.php">

    <?php


    //connect to your database ** EDIT REQUIRED HERE **
    mysql_connect("localhost","notexper_two","three"); //(host, username, password)

    //specify database ** EDIT REQUIRED HERE **
    mysql_select_db("notexper_one") or die("Unable to select database"); //select which database we're using







    $sql = ("select * from CV where user_id = '". $_SESSION['seeker'] ."'");




    $result = mysql_query ($sql);

    while ($row = mysql_fetch_array($result))
    {


    $field1= $row["name"];
    $field7= $row["surname"];
    $field2= $row["address"];
    $field3= $row["address2"];
    $field4= $row["county"];
    $field5= $row["postcode"];
    $field6= $row["country"];






    }

    ?>





    <table width=80%><tr><td valign=top>
    First Name/td><td> <input type="text" name="name" value="<? echo $field1; ?>"></td></tr>
    <tr><td>Surname/tD><td><input type="text" name="surname" value="<? echo $field7; ?>"></td></tr>
    <tr><td>Address/tD><td><input type="text" name="address" value="<? echo $field2; ?>"></td></tr>
    <tr><td>Address 1/tD><td><input type="text" name="address2" value="<? echo $field3; ?>"></td></tr>
    <tr><td>County/tD><td><input type="text" name="county" value="<? echo $field4; ?>"></td></tr>
    <tr><td>Postcode/tD><td><input type="text" name="postcode" value="<? echo $field5; ?>"></td></tr>
    </table>


    <input type="Submit" value="Update">
    </form>

    updated.php

    <?php
    session_start() ;


    $dbhost = 'localhost';
    $dbuser = 'notexper_two';
    $dbpass = 'three';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

    $dbname = 'notexper_one';
    mysql_select_db($dbname);


    $query=("UPDATE CV SET


    name='" . $_GET['name'] . "'
    surname='" . $_GET['surname'] . "',
    address='" . $_GET['address'] . "',
    address2='" . $_GET['address2'] . "',
    postcode='" . $_GET['postcode'] . "',
    country='" . $_GET['country'] . "',







    where user_id = '". $_SESSION['seeker'] ."'");



    mysql_select_db($dbname) or die( "Unable to select database");
    mysql_query($query);
    echo "Record Updated";
    mysql_close();

    ?>

  2. #2
    SitePoint Enthusiast mithra62's Avatar
    Join Date
    Nov 2004
    Location
    Van Nuys
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're missing a comma after the first statement.
    name='" . $_GET['name'] . "'

    You also have an extra comma after country.

    Have you tried viewing the mysql_error()? Also, what's with using $_GET on a form?


Bookmarks

Posting Permissions

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