code for mysql database

Hello, I grabbed this code from the web (dangerous to do). I connect, and can “add contact” but cannot “edit” or “remove.”
Any ideas will be appreciated.
lee

<?php // Connects to your Database $link = mysql_connect('brevardcountylegalai.fatcowmysql.com', 'leefrand100', 'iputmypasswordhere'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db(address_book); if ( $mode=="add") { Print '

Add Contact

Name:
Phone:
Email:

'; } if ( $mode=="added") { mysql_query ("INSERT INTO address (name, phone, email) VALUES ('$name', '$phone', '$email')"); } if ( $mode=="edit") { Print '

Edit Contact

input type=hidden name=id value='; Print $id; print '>
Name:
Phone:
Email:
'; } if ( $mode=="edited") { mysql_query ("UPDATE address SET name = '$name', phone = '$phone', email = '$email' WHERE id = $id"); Print "

Data Updated!

"; } if ( $mode=="remove") { mysql_query ("DELETE FROM address where id=$id"); Print "

Entry has been removed

"; } $data = mysql_query("SELECT * FROM address ORDER BY name ASC") or die(mysql_error()); Print "

Address Book

"; Print ""; Print ""; Print ""; while($info = mysql_fetch_array( $data )) { Print " "; Print " "; Print ""; Print ""; Print ""; } Print "
Name Phone Email Admin
Add Contact
".$info['name'] . "".$info['phone'] . " " .$info['email'] . " EditRemove
"; ?>

Hi there,

You may need to obtain the value of “mode” using GET method before finally using it in your UPDATE and DELETE statement. For example:

[php]$mode=$_GET[‘mode’];[/php]

OK, that’s what I was thinking too. it’s not seeing the modes, as coded.
thanks.
leefrand

Sponsor our Newsletter | Privacy Policy | Terms of Service