There a couple of good tutorials on this sort of thing at
http://www.thickbook.com. Well worth a visit.
I've plucked your shorter example out and re-written it this way:
$sql = "update my_contacts set fname='$fname', name='$lname' where id=$id");
Note the single quotes around the $fname and $lname fields. They are most
likely char types and need the quotes. I didn't know what type id was, so I
left it plain.
This lets you see what your query looks like for debuggin by issuing this:
You execute it this way:
$result = mysql_query( $sql, $connection);
(you can the or die with mysql_error() if you wish)
On the INSERT, just use simple quotes around your char fields, echo the
$sql to see what you are getting, and don't be surprised when it's
something really trivial. I've often had a bad hour or t wo before supper,
then come back downstairs and spotted the missing/extra comma, closing
bracket or whatever.
HTH - Miles Thompson
REALLY RECOMMEND those Julie Meloni tutorials at thickbook. Succinct and to
the point. /mt
At 04:27 PM 12/2/2001 -0500, Kevin Ruiz wrote:
>I'm working on an application that will allow resellers to log into the site
>and see their potential buyers.
>When they log in they see their potential buyers and by clicking a link they
>will get more detailed information about their contacts. They will also
>have a link to update their clients listings.
>As of now I have this set up like this...
>A person logs in and sees their contacts. If they click the update link
>they are takent to a page that lists their contact information. I've put
>the respected variables in the "value" attributes of the input tags. I want
>to make this process as easy as possible. I dont' want them to have to
>update every field if they just want to change a contact's phone number.
>Here's the problem...when they click the button to send the changes they
>still see their old information. I know that this is because I've set the
>value to their old variables. Does anyone know a way to get their old input
>in as the variable value and to still be able to see their new information
>on the next page.
>I also want this information to overwrite any existing record based on the
>potential contact's id. The sql section of the code I have looks like this:
> $sql = "INSERT INTO $table_name
> (id, contactid, fname, lname, title, cnl, address1,
>address2, city, state, postcode,
> country, phone, cell, fax, emailnl, smanager,
>percomplete, nfud, exrevenue, wl, cwl)
> (\"\", \"$contactid\", \"$fname\", \"$lname\",
>\"$title\", \"$cnl\", \"$address1\", \"$address2\", \"$city\", \"$state\",
> \"$postcode\", \"$country\", \"$phone\",
> \"$cell\", \"$fax\", \"$emailnl\", \"$smanager\",
>\"$percomplete\", \"$nfud\", \"$exrevenue\", \"$wl\", \"$cwl\")
> $result = @mysql_query($sql,$connection)
> or die("Couldn't execute query.");
>I know this doesn't overwrite each entry. I've also tried something like
> $sql = mysql_query("update my_contacts set fname=$fname,
>lname=$lname where id=$id");
>Whenever I would try to run that query I would get an error back saying I
>couldn't execute that query.
>If anyone has any ideas I would be more than grateful. Thanks for your
>I'm new to the php/mysql world so if I didn't provide enough relevant code
>let me know.
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]