Jump to content

elginwick

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

elginwick's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=374389:date=May 16 2006, 02:59 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ May 16 2006, 02:59 PM) [snapback]374389[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]<input type=\"hidden\" name=\"ud_id\" value=\" $id \">[/code] Why do you surround $id with spaces??? Then that's why it doesn't update, because there's no record where id = '<space>xx<space> '. [/quote] Thanks for all your help everyone. It was just me being stupid the problem was that on the first page i used <input type=\"hidden\" name=\"ud_id\" value=\" $id \"> and i needed to use <input type=\"hidden\" name=\"ud_id\" value=\" $_POST[sel_id] \"> thanks again.
  2. i changed the session name to a different name and added the echo $sql. it told me what i did but didn't add anything into the database. maybe it would help if i posted some of the code from the page where you can choose what record you want to look at. [Code] if ($_POST[sel_id] == "") { header("Location: somepage.php"); exit; } $query=" SELECT * FROM db WHERE id='$_POST[sel_id]'"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $f_name=mysql_result($result,$i,"f_name"); $l_name=mysql_result($result,$i,"l_name"); $street=mysql_result($result,$i,"street"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zipcode=mysql_result($result,$i,"zipcode"); $phone=mysql_result($result,$i,"phone"); $phone2=mysql_result($result,$i,"phone2"); $classnum=mysql_result($result,$i,"classnum"); $gdate=mysql_result($result,$i,"gdate"); $status=mysql_result($result,$i,"status"); $contact=mysql_result($result,$i,"contact"); $refer=mysql_result($result,$i,"refer"); $referphone=mysql_result($result,$i,"referphone"); $display_block = " <form method=\"post\" action=\"updated.php\"> <input type=\"hidden\" name=\"ud_id\" value=\" $id \"> First Name: <input type=\"text\" name=\"ud_f_name\" value=\" $f_name \"><br> Last Name: <input type=\"text\" name=\"ud_l_name\" value=\" $l_name \"><br> Street: <input type=\"text\" name=\"ud_street\" value=\" $street \"><br> City: <input type=\"text\" name=\"ud_city\" value=\" $city \"><br> State: <input type=\"text\" name=\"ud_state\" value=\" $state \"><br> Zipcode: <input type=\"text\" name=\"ud_zipcode\" value=\" $zipcode \"><br> Phone: <input type=\"text\" name=\"ud_phone\" value=\" $phone \"><br> Phone2: <input type=\"text\" name=\"ud_phone2\" value=\" $phone2\"><br> Session: <input type=\"text\" name=\"ud_classnum\" value=\" $classnum \"><br> Grad Date: <input type=\"text\" name=\"ud_gdate\" value=\" $gdate \"><br> Current Status: <input type=\"text\" name=\"ud_status\" value=\" $status\"><br> Last Contact: <input type=\"text\" name=\"ud_contact\" value=\" $contact\"><br> Referral Person: <input type=\"text\" name=\"ud_refer\" value=\" $refer\"><br> Referral Person Phone: <input type=\"text\" name=\"ud_referphone\" value=\" $referphone \"><br> <input type=\"Submit\" value=\"add\"> </form>"; ++$i; } } ?> <html> <head> <title> </title> </head> <body> <?php echo $display_block; ?> </body> [code] then the second page that the form posts to is [code] <?php $ud_id=$_POST['ud_id']; $ud_f_name=$_POST['ud_f_name']; $ud_l_name=$_POST['ud_l_name']; $ud_city=$_POST['ud_city']; $ud_state=$_POST['ud_state']; $ud_zipcode=$_POST['ud_zipcode']; $ud_phone=$_POST['ud_phone']; $ud_phone2=$_POST['ud_phone2']; $ud_classnum=$_POST['ud_classnum']; $ud_gdate=$_POST['ud_gdate']; $ud_status=$_POST['ud_status']; $ud_contact=$_POST['ud_contact']; $ud_refer=$_POST['ud_refer']; $ud_referphone=$_POST['ud_referphone']; $conn = mysql_connect("localhost", "username", "somepass") or die(mysql_error()); mysql_select_db("somedb",$conn) or die(mysql_error()); $sql = "Update data SET f_name = '$ud_f_name', l_name = '$ud_l_name', city = '$ud_city', state = '$ud_state', zipcode = '$ud_zipcode', phone = '$ud_phone', phone2 = '$ud_phone2', classnum = '$ud_classnum', gdate = '$ud_gdate', status = '$ud_status', contact = '$ud_contact', refer = '$ud_refer', referphone = '$ud_referphone' WHERE id = '$ud_id'"; mysql_query($sql) or die(mysql_error()); echo "$sql <br>"; echo "Record Updated"; mysql_close(); ?> [code] any suggestions? thanks again
  3. I have reworked it a bit, and now this is what i have <?php $ud_id=$_POST['ud_id']; $ud_f_name=$_POST['ud_f_name']; $ud_l_name=$_POST['ud_l_name']; $ud_city=$_POST['ud_city']; $ud_state=$_POST['ud_state']; $ud_zipcode=$_POST['ud_zipcode']; $ud_phone=$_POST['ud_phone']; $ud_phone2=$_POST['ud_phone2']; $ud_session=$_POST['ud_session']; $ud_gdate=$_POST['ud_gdate']; $ud_status=$_POST['ud_status']; $ud_contact=$_POST['ud_contact']; $ud_refer=$_POST['ud_refer']; $ud_referphone=$_POST['ud_referphone']; $conn = mysql_connect("localhost", "username", "somepass") or die(mysql_error()); mysql_select_db("somedb",$conn) or die(mysql_error()); mysql_query ("Update data SET f_name = '$ud_f_name', l_name = '$ud_l_name', city = '$ud_city', state = '$ud_state', zipcode = '$ud_zipcode', phone = '$ud_phone', phone2 = '$ud_phone2', session = '$ud_session', gdate = '$ud_gdate', status = '$ud_status', contact = '$ud_contact', refer = '$ud_refer', referphone = '$ud_referphone' WHERE id = '$ud_id'") or die(mysql_error()); echo "Record Updated"; mysql_close(); ?> the problem is that it seems to work, as in it says record updated, but it doesn't actually updat anything. i have tried everything, and i don't understand what to do next. thanks in advance.
  4. hello, i have been trying to write an update code, but it isn't working. any suggestions. i link from one php code that allows me to pick which information i want to see based on an id, it then refers to this page <?php $conn = mysql_connect("localhost", "username", "somepass") or die(mysql_error()); mysql_select_db("selectdatakbase",$conn) or die(mysql_error()); $ud_id=$_POST['ud_id']; $f_name=$_POST['f_name']; $ud_l_name=$_POST['ud_l_name']; $ud_city=$_POST['ud_city']; $ud_state=$_POST['ud_state']; $ud_zipcode=$_POST['ud_zipcode']; $ud_phone=$_POST['ud_phone']; $ud_phone2=$_POST['ud_phone2']; $ud_session=$_POST['ud_session']; $ud_gdate=$_POST['ud_gdate']; $ud_status=$_POST['ud_status']; $ud_contact=$_POST['ud_contact']; $ud_refer=$_POST['ud_refer']; $ud_referphone=$_POST['ud_referphone']; $query = "UPDATE data while f_name = '$ud_f_name', $l_name = '$ud_l_name', $city = '$ud_city', $state = '$ud_state', zipcode = '$ud_zipcode', phone = '$ud_phone', phone2 = '$ud_phone2', session = '$ud_session', gdate = '$ud_gdate',status = '$ud_status', contact = '$ud_contact', refer = '$ud_refer', referphone = '$ud_referphone' WHERE id = '$ud_id'"; mysql_query($query) or die(mysql_error()); echo "Record Updated"; mysql_close(); ?> i don't know if it makes any sense, but any help would be greatly appreciated. thanks.
  5. I tried all those things but the error is still exactly the same. i think i am going to look at a different way of doing it. thanks for all your help.
  6. I am trying to load multiple pieces of information from a form that is submitted. for some reason i am getting an errror in one place, but not in the other place. example //start code $add_master = "INSERT INTO master_name values ('', now(), now(), '$_POST[f_name]', '$_POST[l_name]', '$_POST[dob]', '$_POST[ss]', '$_POST[session]') address values ('', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zipcode]')"; mysql_query($add_master) or die(mysql_error()); //end code there are no errors for this script but then in this script //start code 7 if (($_POST[address]) || ($_POST[city]) || ($_POST[state]) || ($_POST[zipcode])) { 8 $add_address = "insert into address values ('', '$_POST[address]', '$_POST[city]', 9 '$_POST[state]', '$_POST[zipcode]')"; 10 mysql_query($add_address) or die(mysql_error()); 11 } //end code there is an errror here is what it says. You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'address values ('', '111 Main St.', 'san franscisco', 'ca', '90215')' at line I am using mysql 4.0.16 Not sure what to do, any help would be greatly appreciated. thanks in advance
  7. I am still getting the same error, it doesn't make sense to me. i have checked it over and over again, but to no avail.
  8. I am trying to create a simple mailing list that the user can subscribe and unsubscribe to. I can get the new subscriptions and it works, but when i try to unsubscribe, i get this error query was empty i don't know what is going wrong. Thanks. here is the code: <?php function doDB() { global $conn; $conn = mysql_connect("localhost", "user", "pass"); mysql_select_db("db",$conn) or die(mysql_error()); } function emailChecker($email) { global $conn, $check_result; $check = "select id from subscribers where email = '$email'"; $check_result = mysql_query($check,$conn) or die (mysql_error()); } if ($_POST[op] != "ds") { $display_block = " <form method=POST action=\"$_SERVER[PHP_SELF]\"> <p><font color=\"#164059\">Your E-Mail Address:<br> <input type=text name=\"email\" size=40 maxlength=150> <p>Action:<br> <input type=radio name=\"action\" value=\"sub\" checked> subscribe <input type=radio name=\"action\" value=\"unsub\"> unsubscribe <input type=\"hidden\" name=\"op\" value=\"ds\"> <p><input type=submit name=\"submit\" value=\"Submit Form\"></p> </form>"; } else if (($_POST[op] == "ds") && ($_POST[action] == "sub")) { if ($_POST[email] == "") { header("Location: manage.php"); exit; } doDB(); emailChecker($_POST[email]); if (mysql_num_rows($check_result) < 1) { $sql = "insert into subscribers values('', '$_POST[email]')"; $result = mysql_query($sql,$conn) or die(mysql_error()); $display_block = "<p>Thanks for signing up!</p>"; } else { $display_block = "<p>Your're already subscribed!</p>"; } } else if (($_POST[op] == "ds") && ($_POST[action] == "unsub")) { if ($_POST[email] == "") { header("Location: manage.php"); exit; } doDB(); emailChecker($_POST[email]); if (mysql_num_rows($check_result) < 1) { $display_block = "<p>Couldn't find your address!</p> <P> No action was taken.</p>"; } else { $id = mysql_result($check_result, 0, "id"); $sql = "delete from subscribers where id = '$id'"; $result = mysql_query($sql,$conn) or die(mysql_error()); $display_block = "<p>You're Unsubscribed!</p>"; } } ?> <html> <head> <title>Newsletter Subscription</title> <style type="text/css"> <!-- .style5 { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #164059; } body,td,th { font-family: Arial, Helvetica, sans-serif; color: #164059; } body { background-color: #FFFFFF; } a:link { color: #164059; text-decoration: none; } a:visited { text-decoration: none; color: #164059; } a:hover { text-decoration: none; color: #164059; } a:active { text-decoration: none; color: #164059; } --> </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body> <div align="center"><span class="style5"><?php echo "$display_block"; ?></span></div> </body> </html>
×
×
  • 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.