PHP - Error: Duplicate Entry, Simple Edit Form
I have a table called "colors". It has 2 columns, id and color.
All I'm trying to do is pull the data into the form, then edit the colors (for example - misspelled, etc.) Then submit it back to the table. Here is the code that pulls the data into a form so I can edit it: Code: [Select] <form action="adminupdatecolors.php" method="post"> <table width="500" border="1" cellpadding="10"> <tr> <td>Color Options:</td> <td> <? $result = mysql_query("SELECT * FROM colors"); while ($row = mysql_fetch_assoc($result)) { echo '<input type="text" name="color[]" value="' . $row['color'] . '"/>' . $row['id'] . '<br />'; } ?> </td> </tr> <tr> <td> </td> <td><input type="Submit" value="Update Colors"></td> </tr> </form> </table> Here is my update script: Code: [Select] <?php include("config.php"); include("db.php"); $id=$_POST['id']; $color=$_POST['color']; $result = mysql_query("SELECT id FROM colors ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $id = $row['id']; } $sql = "DELETE FROM colors WHERE id='$id'"; mysql_query($sql) or die("Error: ".mysql_error()); foreach ($color as $colorvalue) { $sql2 = "INSERT INTO colors (id,color) VALUES ($id,'$color')"; mysql_query($sql2) or die("Error: ".mysql_error()); } header("Location: " . $config_basedir . "adminhome.php"); ?> Similar TutorialsHi I am getting this error message and don't know why. please help this is the message " Error: Duplicate entry '' for key 1 " Here is the code Code: [Select] <?php include'../DB-connection.php'; $sql="INSERT INTO Company(CompanyName,Address,Logo,PhoneNumber,ContactPerson) VALUES('".mysql_real_escape_string($_POST[CompanyName])."', '".mysql_real_escape_string($_POST[Address])."', '".mysql_real_escape_string($_POST[Logo])."', '".mysql_real_escape_string($_POST[PhoneNumber])."', '".mysql_real_escape_string($_POST[ContactPerson])."')"; if(!mysql_query($sql,$con)) { die(' Error: '. mysql_error()); } echo " <center>your compnay info added       <a href='User-Login.php'>Login to Post a job</a> </center>" ; mysql_close($con) ?> Hi there, I am trying to add a bit of php to capture an email address and add it to mysql database. This part works fine but i get this message: Error: Duplicate entry '' for key 'PRIMARY' How do i get rid of this error? Thanks! <?php session_start(); include('include/includes.php'); $cart = Cart::CreateInstance(); if(isset($_GET)){ foreach($_GET as $k=>$v){ $smarty->assign($k,$v); } } if(isset($_GET['remove'])){ $cart->RemoveItems($_GET['remove'],1); } if(isset($_GET['removeAll'])){ $cart->RemoveItems($_GET['removeAll'],$_GET['counts']); } if(isset($_GET['emptyCart'])){ if($_GET['emptyCart']){ $cart->EmptyCart(); header("Location: cart.html"); exit(0); }} if(isset($_GET['add'])){ $itemId = $_GET['add']; $size = $_GET['size']; if (isset($_GET['qty'])) { $qty = $_GET['qty']; } else { $qty = 1; } $cart->addItems($itemId.'-'.$size, array($size,$itemId), $qty); } $cart = Cart::CreateInstance(); $cartBox = $cart->GetCart(); //print_r($cartBox); $total = 0; $subTotal = array(); $db = new DB(); $prods = $db->select("SELECT friendly,name,id FROM products"); $smarty->assign('prods',$prods); if(is_array($cartBox)){ foreach($cartBox as $key=>$item){ $id = $cartBox[$key]['data']->_itemData[1]; $products = $db->select("SELECT detail,image,friendly,name FROM products WHERE id='$id'"); $detailjson = json_decode($products[0]['detail']); foreach($detailjson as $detail){ list($k, $v) = split_by_colon($detail); if($k == $cartBox[$key]['data']->_itemData[0]){ $price = $v;} } $cartBox[$key]['data']->_itemData[3] = $products[0]['image']; $cartBox[$key]['data']->_itemData[6] = $products[0]['name']; $cartBox[$key]['data']->_itemData[2] = $products[0]['friendly']; $cartBox[$key]['data']->_itemData[5] = $price; $sub = (int)$item['count'] * $price; $cartBox[$key]['data']->_itemData[4] = $sub; $total += $sub; } } else { $cartBox = array(); } $count = $cart->GetItemsCount(); $shipping = (int)0; if($total>0&&$total<5){ $shipping = 2.99; }elseif($total>5&&$total<10){ $shipping = 3.99; }elseif($total>10&&$total<15){ $shipping = 4.99; }elseif($total>15&&$total<20){ $shipping = 5.99; }elseif($total>20&&$total<30){ $shipping = 6.99; }elseif($total>30&&$total<40){ $shipping = 7.99; }elseif($total>40&&$total<50){ $shipping = 8.99; }elseif($total>50&&$total<60){ $shipping = 9.99; }elseif($total>60&&$total<70){ $shipping = 10.99; }elseif($total>70&&$total<80){ $shipping = 11.99; }elseif($total>80&&$total<90){ $shipping = 12.99; }elseif($total>90&&$total<100){ $shipping = 15.99; }elseif($total>100&&$total<110){ $shipping = 16.99; }elseif($total>110&&$total<120){ $shipping = 17.99; }elseif($total>120&&$total<130){ $shipping = 18.99; }elseif($total>130&&$total<140){ $shipping = 19.99; }elseif($total>140&&$total<150){ $shipping = 20.99; }elseif($total>150&&$total<160){ $shipping = 21.99; }elseif($total>160&&$total<170){ $shipping = 22.99; }elseif($total>170&&$total<180){ $shipping = 23.99; }elseif($total>180){ $shipping = 24.99; } /* 0 - 4.99 = 2.99 5 - 9.99 = 3.99 10 - 14.99 = 4.99 15 - 19.99 = 5.99 20 - 29.99 = 6.99 30 - 39.99 = 7.99 40 - 49.99 = 8.99 50 - 69.99 = 9.99 70 - 99.99 = 10.99 100+ = 12.99 */ if(isset($_GET['eushipping'])||(isset($_POST['rec_country'])&&$_POST['rec_country']!='uk')){ if($_POST['rec_country']=='au' || $_GET['country']=='au'){ //Set shipping for Austria $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='be' || $_GET['country']=='be'){ //Set shipping for Belgium $shipping = ceil($total/60.00)*20.00; }elseif($_POST['rec_country']=='bu' || $_GET['country']=='bu'){ //Set shipping for Bulgaria $shipping = ceil($total/60.00)*50.00; }elseif($_POST['rec_country']=='cy' || $_GET['country']=='cy'){ //Set shipping for Cyprus $shipping = ceil($total/60.00)*108.00; }elseif($_POST['rec_country']=='cz' || $_GET['country']=='cz'){ //Set shipping for Czech Republic $shipping = ceil($total/60.00)*33.00; }elseif($_POST['rec_country']=='de' || $_GET['country']=='de'){ //Set shipping for Denmark $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='es' || $_GET['country']=='es'){ //Set shipping for Estonia $shipping = ceil($total/60.00)*45.00; }elseif($_POST['rec_country']=='fi' || $_GET['country']=='fi'){ //Set shipping for Finalnd $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='fr' || $_GET['country']=='fr'){ //Set shipping for France $shipping = ceil($total/60.00)*28.00; }elseif($_POST['rec_country']=='ge' || $_GET['country']=='ge'){ //Set shipping for Germany $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='gr' || $_GET['country']=='gr'){ //Set shipping for Greece $shipping = ceil($total/60.00)*50.00; }elseif($_POST['rec_country']=='hu' || $_GET['country']=='hu'){ //Set shipping for Hungary $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='ir' || $_GET['country']=='ir'){ //Set shipping for Ireland $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='it' || $_GET['country']=='it'){ //Set shipping for Italy $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='la' || $_GET['country']=='la'){ //Set shipping for Latvia $shipping = ceil($total/60.00)*42.00; }elseif($_POST['rec_country']=='li' || $_GET['country']=='li'){ //Set shipping for Lithuania $shipping = ceil($total/60.00)*35.00; }elseif($_POST['rec_country']=='lu' || $_GET['country']=='lu'){ //Set shipping for Luxembourg $shipping = ceil($total/60.00)*20.00; }elseif($_POST['rec_country']=='ma' || $_GET['country']=='ma'){ //Set shipping for Malta $shipping = ceil($total/60.00)*108.00; }elseif($_POST['rec_country']=='ne' || $_GET['country']=='ne'){ //Set shipping for Netherlands $shipping = ceil($total/60.00)*25.00; }elseif($_POST['rec_country']=='no' || $_GET['country']=='no'){ //Set shipping for Norway $shipping = ceil($total/60.00)*37.00; }elseif($_POST['rec_country']=='pol' || $_GET['country']=='pol'){ //Set shipping for Poland $shipping = ceil($total/60.00)*35.00; }elseif($_POST['rec_country']=='por' || $_GET['country']=='por'){ //Set shipping for Portugal $shipping = ceil($total/60.00)*30.00; }elseif($_POST['rec_country']=='ro' || $_GET['country']=='ro'){ //Set shipping for Romania $shipping = ceil($total/60.00)*48.00; }elseif($_POST['rec_country']=='slv' || $_GET['country']=='slv'){ //Set shipping for Slovakia $shipping = ceil($total/60.00)*32.00; }elseif($_POST['rec_country']=='slk' || $_GET['country']=='slk'){ //Set shipping for Slovenia $shipping = ceil($total/60.00)*29.00; }elseif($_POST['rec_country']=='sp' || $_GET['country']=='sp'){ //Set shipping for Spain $shipping = ceil($total/60.00)*36.00; }elseif($_POST['rec_country']=='swe' || $_GET['country']=='swe'){ //Set shipping for Sweden $shipping = ceil($total/60.00)*32.00; }elseif($_POST['rec_country']=='swi' || $_GET['country']=='swi'){ //Set shipping for Switzerland $shipping = ceil($total/60.00)*55.00; }elseif($_POST['rec_country']=='ukh' || $_GET['country']=='ukh'){ //Set shipping for UK - Highlnads and Islands $shipping = ceil($total/60.00)*18.00; }elseif($_POST['rec_country']=='ukn' || $_GET['country']=='ukn'){ //Set shipping for UK - Northern Island $shipping = ceil($total/60.00)*18.00; }elseif($_POST['rec_country']=='jng' || $_GET['country']=='jng'){ //Set shipping for Jersey and Guernsey $shipping = ceil($total/60.00)*34.00; } } /* */ if(isset($_GET['count'])){ echo (int)$count; exit; } if(isset($_GET['order'])){ if($_GET['order']){ }} if(isset($_GET['ajax'])){ $noAjax = $_GET['ajax']; }else{ $noAjax = false; } $smarty->assign('noAjax',$noAjax); if(isset($_GET['t'])){ $t=$_GET['t'].'.tpl'; } else { $t = 'cart.tpl'; } if(isset($_POST['cmd'])) { $_SESSION['paypal'] = $_POST; //print_r($_POST); } if(isset($_POST['rec_houseA1'])){ $filename = time().'-'.rand(1,499); $paypal = $_SESSION['paypal']; unset($paypal['checkout_x']); unset($paypal['checkout_y']); $_SESSION['addresses'] = $_POST; $File = 'sales/'.$filename.'.php'; $Handle = fopen($File, 'x'); fwrite($Handle,'<? '); fwrite($Handle,'$cart = array('); foreach($cartBox as $k=>$v){ fwrite($Handle,'"'.$k.'"=>array('); foreach($v as $key=>$value){ if(is_object($value)){ fwrite($Handle,'"'.$key.'"=>(object)array('); foreach($value as $keys=>$values){ if(is_array($values)){ fwrite($Handle,'"'.$keys.'"=>array('); foreach($values as $keyd=>$valued){ fwrite($Handle, '"'.$keyd.'"=>"'.$valued.'",'); } fwrite($Handle,'""=>""),'); }else{ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } } fwrite($Handle,'""=>""),'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,'""=>""),'); } //$total += $_POST['shipping']; fwrite($Handle,'"total"=>"'.$total.'");'); fwrite($Handle,' '); fwrite($Handle,'$detail = array('); foreach($_POST as $k=>$v){ if(is_array($v)){ fwrite($Handle,'array('); foreach($v as $key=>$value){ if(is_array($value)){ fwrite($Handle,'array('); foreach($value as $keys=>$values){ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } fwrite($Handle,')'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,')'); }else{ fwrite($Handle, '"'.$k.'"=>"'.$v.'",'); } } fwrite($Handle,'""=>"");'); fwrite($Handle,' '); fwrite($Handle,'$paypal = array('); foreach($paypal as $k=>$v){ if(is_array($v)){ fwrite($Handle,'array('); foreach($v as $key=>$value){ if(is_array($value)){ fwrite($Handle,'array('); foreach($value as $keys=>$values){ fwrite($Handle, '"'.$keys.'"=>"'.$values.'",'); } fwrite($Handle,')'); }else{fwrite($Handle, '"'.$key.'"=>"'.$value.'",');} } fwrite($Handle,')'); }else{ fwrite($Handle, '"'.$k.'"=>"'.$v.'",'); } } fwrite($Handle,'""=>"");'); fwrite($Handle,' '); fwrite($Handle,'$shipping = "'.$shipping.'"; '); fwrite($Handle,'$subtotal = "'.$total.'"; '); $totals = $total+$shipping; fwrite($Handle,'$totals = "'.$totals.'";'); fclose($Handle); $smarty->assign('filename',$filename); $smarty->assign('shipping',$shipping); $smarty->assign('paypal',$paypal); //print_r($paypal); $smarty->display('paypal.tpl'); }else{ $smarty->assign('total',$total+$shipping); $smarty->assign('itemsInBox',$count); $smarty->assign('cartBox',$cartBox); $smarty->assign('shipping',$shipping); $style = $db->select("SELECT * FROM styles WHERE `name`='default'"); $smarty->assign('style',$style); $smarty->display($t); } ?> <?php $con = mysql_connect("organicgrowshopcouk.fatcowmysql.com","worm","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ogs_mailinglist1", $con); $sql="INSERT INTO mailinglist (email) VALUES ('$_POST[rec_email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> Hey folks, Sorry for being a pain in the ass. I am trying to submit data to my database via a form and when I click Submit, I get: Duplicate entry '' for key 1 I understand that it means I have a duplicate entry with the ID of 1 or something like that. I can't find where the issue is. Here is the form: <form actin="" id="settings" name="settings"> <table class="listing form" cellpadding="0" cellspacing="0"> <tr> <th class="full" colspan="2"><?php echo $lang_settings; ?></th> </tr> <tr> <th colspan="2"><?php echo $lang_settings_description; ?></th> </tr> <tr> <td><?php echo $lang_sitename; ?>: </td> <td><input type="text" name="sitename" value="<?php echo $site_name; ?>" width="172" /> <em>Site name for logo</em></td> </tr> <tr> <td><?php echo $lang_email; ?>: </td> <td><input type="text" name="email" value="<?php echo $site_email; ?>" width="172" /> <em>Your email address</em></td> </tr> <tr> <td><?php echo $lang_yourname; ?>: </td> <td><input type="text" name="name" value="<?php echo $your_name; ?>" width="172" /> <em>Your own name</em></td> </tr> <tr> <td><?php echo $lang_meta_description; ?>: </td> <td><input type="text" name="meta-description" value="<?php echo $description; ?>" width="172" /> <em>SEO</em></td> </tr> <tr> <td><?php echo $lang_keywords; ?>: </td> <td><input type="text" name="meta-keywords" value="<?php echo $keywords; ?>" width="172" /> <em>Separate with Commas</em></td> </tr> <tr> <td><input type="submit" class="button" name="submit" value="<?php echo $lang_button_savesettings; ?>"></td> </tr> </table> </form> Here is the Insert code: $insert = "INSERT INTO settings (site_name, description, keywords, email, name) VALUES ('$sitename', '$meta_description', '$meta_keywords', '$site_email', '$your_name')"; mysql_query($insert) or die(mysql_error()); Can anyone please tell me where I am going wrong here? Much appreciated. Hi.. So im currently working on a script.. My script generates a "oid" based on timestamp. Ive made the "oid" field unique in my db, so if i do a quick refresh i get the message: Duplicate entry '1283195988' for key 'oid' Is there some way i can check if its a dublicate, and if it is + it with 1 or something? Hey guys! I know, I know this problem is EVERYWHERE but i just dont understand! I have a solid knowlage of php but my SQL skills are low, so i dont know too much about Keys and stuff. But my error is: Duplicate entry '' for key 2. The thing that im working on at this section is logging in with facebook. The code that presents my error is: $sql = "SELECT * FROM users WHERE uid=".$uid; $fbid = mysql_query($sql); $num_rows = mysql_num_rows($fbid); if(mysql_num_rows($fbid) < 1) { echo "You are not logged in. "; mysql_query("INSERT INTO `users` (`uid`) VALUES ('".$uid."')") or die(mysql_error()); } else { mysql_query("UPDATE users SET logged = '1' WHERE uid=".$uid); //mysql_query("UPDATE users SET full_name = $me WHERE uid=".$uid); echo "Your Logged in "; echo $me['name']; ?> Continue to <a href="removed :)"> My Settings </a>. <? } Any help is welcome Hi everyone, I need a little bit of help finishing off my code. Ive managed to get this far. Code: [Select] <?php mysql_connect("") or die ("Not Connected to MYSQL"); echo "</br>"; mysql_select_db("") or die ("Not Connected to DB"); // Database Connection stuff $partialNumber = $_POST['partialNumber']; // Post the Partial number $partialNumber = strtoupper($partialNumber); $numberSearch = mysql_query("SELECT * FROM product_option_value_description WHERE name LIKE '%$partialNumber%'") or die (mysql_error()); // Query to select the key number //Query to get product ID // $productId = "SELECT product_id FROM product_option_value_description"; //Query to get product ID // while ($keyNumber = mysql_fetch_array($numberSearch)) { $id = $keyNumber['product_id']; // Query for the images // $query = "SELECT image FROM product WHERE product_id = '$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result) or die(mysql_error()); $query2 = "SELECT product_option_id FROM product_option_value WHERE product_id = '$id'"; $result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2) or die(mysql_error()); $query3 = "SELECT product_option_value_id FROM product_option_value WHERE product_id = '$id'"; $result3 = mysql_query($query3); $row3 = mysql_fetch_array($result3) or die(mysql_error()); ?> <div> <br /><br /> Key Number: <? echo $keyNumber['name']; ?></a> <form action="http://www.co.uk/teststore/index.php?route=checkout/cart" method="post" enctype="multipart/form-data" id="product"> <br /> <table style="width: 100%;"> <tr> <td> Colour: <select name="option[<? echo $row2['product_option_id']; ?>]"> <option value="<? echo $row3['product_option_value_id']; ?>"></option> </select></td> </tr> </table> <div class="content"> Qty: <input type="text" name="quantity" size="3" value="1" /> <input type="hidden" name="product_id" value="<? echo $id; ?>" /> <input name="submit" type="submit" value="Add to Cart" /> </div> </form> <? echo $row3['product_option_value_id']; ?> </div> <br /> <img height="150" width="150" src='http://www.co.uk/teststore/image/<? echo $row['0']; ?>'/> <? } ?> And here is my SQL Table code. Code: [Select] product_option_value_id product_option_id product_id 599 302 49 598 302 49 589 297 42 588 297 42 So as you can probably tell, it is a search program that looks for products on a shopping cart. The products will have different option values, and the php script will grab the option values and echo them in a form to post back to the cart to add the product to the basket. The problem is that the "product_option_value_id" can have lots of different values, but my code echos only the first one it finds. So when I click the add to cart button, it will only add the first option value for the product it finds. For some reason I am having a hard time explaining this, so I hope someone can help me. Thanks for looking. What exactly does the entry in the title mean? I cannot make sense out of it. I would appreciate if somebody can shed some light in. The error message occurs when I try to vote with the voting system I created. Please i ran into this problem help me : Code: [Select] <p>Posted by <a href=""> <?php if(isset($_GET['id'])) { $tpid=$_GET['id']; } else { $tpid=$_POST['id']; } include"header.php"; $sql="SELECT*FROM topics WHERE topicsid='$tpid'"; $result=mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"{$row['topics_by']}"; echo"</a></p>"; echo"<p>"; echo"{$row['topics_subject']}"; echo" <p align='left'><img src='speakout_1.png'/>"; echo"{$row['topics_content']}"; echo"<p class='post-footer align-right'> <a href='' class='comments'>"; session_start(); if(isset($_SESSION['views'])) $_SESSION['views']=$_SESSION['views']+1; else $_SESSION['views']=1; echo"Comments:".$_SESSION['views']; echo"</a>"; echo"<span class='date'>"; echo"{$row['topics_date']}"; } ?></span> </p> </div> <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"></td> <td><?php include"header.php"; $sql="SELECT post_content,post_by FROM post WHERE topicsID='$tpid'"; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"<strong>{$row['post_by']}</strong>: {$row['post_content']}"."</br>"; } ?></td> </tr> </table> <?php include"header.php"; if(isset($_POST['submit'])) { $comment=mysql_real_escape_string(trim($_POST['comment'])); $name=mysql_real_escape_string(trim($_POST['name'])); $hidden=$_POST['id']; if($comment!=='' && $name!=='') { $ins="INSERT INTO post(topicsID,post_content,post_by)VALUES('$hidden','$comment','$name')"; mysql_query($ins) or die(mysql_error()); } else { echo"you cannot post an empty field"; } } ?> <h3>Post your comments here</h3> <form action=''method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> Name:<input type="text"name="name"/> <input class="button" type="submit"name="submit"value="submit" /> <input type="hidden"name="id"value='<?php echo "$tpid"; ?>'/> </p> </form> <br /> </div> When there is a duplicate entry in my database, I would like it to go to the another page that indicates the error, rather than the "Error: Duplicate entry 'username' for key 1". It happens if someone is going to join and there is a duplicate entry. I would rather it show one of my customized php pages rather than a black page stating the error. I've tried to catch the entry with some php code but it bypasses it and continues with the duplicate error. I would appreciate any direction with this. Thanks! hey guys, I'm getting a problem uploading my csv file to mysql database, the code on the top half just makes sure that I don't import data that I don't want into the database, numbers that are too high or too low on certain rows, and the second half is importing the array that I create from the csv file into the database however I'm getting the following error
Duplicate entry 'Array' for key 'strProductCode'
Now I've never had this error before and I'm not sure what's causing it so any help would be very much appreciated
$data = array(); if (($handle = fopen("stock.csv", "r")) !== FALSE) { while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) { // only add rows to the array where the 4th column value is greater than or equal to 10 if(($row[3] >= 10 && $row[4] >= 5) OR ($row[3] >= 0 AND $row[4] > 5)){ if($row[4] < 1000){ $data[] = $row; } } } foreach ($data as &$value) { mysql_query("INSERT INTO tblProductData (intProductDataId, strProductCode, strProductName, strProductDesc, strProductStock, strProductCost, dtmDiscontinued, dtmAdded, stmTimestamp) VALUES(null, '$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', 'time', 'added', 'time') ") or die(mysql_error()); } } I wrote a site for work that holds employee schedule. By demand of my manager she would like an edit function with out having to re-enter the hole thing. She is very BLOND!! the layout has to stay the same other wise she will never figure it out. i need to be query the db pull the info, edit it and send it back or get it info and then delete then enter new. this is the code i already use to query the info from the db: Code: [Select] <? ini_set("display_errors", "1"); error_reporting(E_ALL); include("dbinfo.php"); mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM schedule ORDER BY date DESC LIMIT 2"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $date=mysql_result($result,$i,'date'); $urn=mysql_result($result,$i,'urn'); $date0=mysql_result($result,$i,'date0'); $date1=mysql_result($result,$i,'date1'); $date2=mysql_result($result,$i,'date2'); $date3=mysql_result($result,$i,'date3'); $date4=mysql_result($result,$i,'date4'); $date5=mysql_result($result,$i,'date5'); $date6=mysql_result($result,$i,'date6'); $date7=mysql_result($result,$i,'date7'); $day=mysql_result($result,$i,"day"); $day1=mysql_result($result,$i,"day1"); $day2=mysql_result($result,$i,"day2"); $day3=mysql_result($result,$i,"day3"); $day4=mysql_result($result,$i,"day4"); $day5=mysql_result($result,$i,"day5"); $day6=mysql_result($result,$i,"day6"); $day7=mysql_result($result,$i,"day7"); $row1=mysql_result($result,$i,"row1"); $row2=mysql_result($result,$i,"row2"); $row3=mysql_result($result,$i,"row3"); $row4=mysql_result($result,$i,"row4"); $row5=mysql_result($result,$i,"row5"); $row6=mysql_result($result,$i,"row6"); $row7=mysql_result($result,$i,"row7"); $row8=mysql_result($result,$i,"row8"); $row9=mysql_result($result,$i,"row9"); $row10=mysql_result($result,$i,"row10"); $row11=mysql_result($result,$i,"row11"); $row12=mysql_result($result,$i,"row12"); $row13=mysql_result($result,$i,"row13"); $row14=mysql_result($result,$i,"row14"); $row15=mysql_result($result,$i,"row15"); $row16=mysql_result($result,$i,"row16"); $row17=mysql_result($result,$i,"row17"); $row18=mysql_result($result,$i,"row18"); $row19=mysql_result($result,$i,"row19"); $row20=mysql_result($result,$i,"row20"); $row21=mysql_result($result,$i,"row21"); $row22=mysql_result($result,$i,"row22"); $row23=mysql_result($result,$i,"row23"); $row24=mysql_result($result,$i,"row24"); $row25=mysql_result($result,$i,"row25"); $row26=mysql_result($result,$i,"row26"); $row27=mysql_result($result,$i,"row27"); $row28=mysql_result($result,$i,"row28"); $row29=mysql_result($result,$i,"row29"); $row30=mysql_result($result,$i,"row30"); $row31=mysql_result($result,$i,"row31"); $row32=mysql_result($result,$i,"row32"); $row33=mysql_result($result,$i,"row33"); $row34=mysql_result($result,$i,"row34"); $row35=mysql_result($result,$i,"row35"); $row36=mysql_result($result,$i,"row36"); $row37=mysql_result($result,$i,"row37"); $row38=mysql_result($result,$i,"row38"); $row39=mysql_result($result,$i,"row39"); $row40=mysql_result($result,$i,"row40"); $row41=mysql_result($result,$i,"row41"); $row42=mysql_result($result,$i,"row42"); $row43=mysql_result($result,$i,"row43"); $row44=mysql_result($result,$i,"row44"); $row45=mysql_result($result,$i,"row45"); $row46=mysql_result($result,$i,"row46"); $row47=mysql_result($result,$i,"row47"); $row48=mysql_result($result,$i,"row48"); $row50=mysql_result($result,$i,"row50"); $row51=mysql_result($result,$i,"row51"); $row52=mysql_result($result,$i,"row52"); $row53=mysql_result($result,$i,"row53"); $row54=mysql_result($result,$i,"row54"); $row55=mysql_result($result,$i,"row55"); $row56=mysql_result($result,$i,"row56"); $row57=mysql_result($result,$i,"row57"); $row58=mysql_result($result,$i,"row58"); $row59=mysql_result($result,$i,"row59"); $row60=mysql_result($result,$i,"row60"); $row61=mysql_result($result,$i,"row61"); $row62=mysql_result($result,$i,"row62"); $row63=mysql_result($result,$i,"row63"); $row64=mysql_result($result,$i,"row64"); $row65=mysql_result($result,$i,"row65"); $drive1=mysql_result($result,$i,"drive1"); $drive2=mysql_result($result,$i,"drive2"); $drive3=mysql_result($result,$i,"drive3"); $drive4=mysql_result($result,$i,"drive4"); $drive5=mysql_result($result,$i,"drive5"); $drive6=mysql_result($result,$i,"drive6"); $drive7=mysql_result($result,$i,"drive7"); $drive8=mysql_result($result,$i,"drive8"); $drive9=mysql_result($result,$i,"drive9"); $drive10=mysql_result($result,$i,"drive10"); $drive11=mysql_result($result,$i,"drive11"); $drive12=mysql_result($result,$i,"drive12"); $drive13=mysql_result($result,$i,"drive13"); $drive14=mysql_result($result,$i,"drive14"); $drive15=mysql_result($result,$i,"drive15"); $drive16=mysql_result($result,$i,"drive16"); $drive17=mysql_result($result,$i,"drive17"); $drive18=mysql_result($result,$i,"drive18"); $drive19=mysql_result($result,$i,"drive19"); $drive20=mysql_result($result,$i,"drive20"); $drive21=mysql_result($result,$i,"drive21"); $drive22=mysql_result($result,$i,"drive22"); $drive23=mysql_result($result,$i,"drive23"); $drive24=mysql_result($result,$i,"drive24"); $drive25=mysql_result($result,$i,"drive25"); $drive26=mysql_result($result,$i,"drive26"); $drive27=mysql_result($result,$i,"drive27"); $drive28=mysql_result($result,$i,"drive28"); $drive29=mysql_result($result,$i,"drive29"); $drive30=mysql_result($result,$i,"drive30"); $drive31=mysql_result($result,$i,"drive31"); $drive32=mysql_result($result,$i,"drive32"); $drive33=mysql_result($result,$i,"drive33"); $drive34=mysql_result($result,$i,"drive34"); $drive35=mysql_result($result,$i,"drive35"); $drive36=mysql_result($result,$i,"drive36"); $drive37=mysql_result($result,$i,"drive37"); $drive38=mysql_result($result,$i,"drive38"); $drive39=mysql_result($result,$i,"drive39"); $drive40=mysql_result($result,$i,"drive40"); $drive41=mysql_result($result,$i,"drive41"); $drive42=mysql_result($result,$i,"drive42"); $drive43=mysql_result($result,$i,"drive43"); $drive44=mysql_result($result,$i,"drive44"); $drive45=mysql_result($result,$i,"drive45"); $drive46=mysql_result($result,$i,"drive46"); $drive47=mysql_result($result,$i,"drive47"); $drive48=mysql_result($result,$i,"drive48"); $drive49=mysql_result($result,$i,"drive49"); $drive50=mysql_result($result,$i,"drive50"); $drive51=mysql_result($result,$i,"drive51"); $drive52=mysql_result($result,$i,"drive52"); $drive53=mysql_result($result,$i,"drive53"); $drive54=mysql_result($result,$i,"drive54"); $drive55=mysql_result($result,$i,"drive55"); $drive56=mysql_result($result,$i,"drive56"); $drive57=mysql_result($result,$i,"drive57"); $drive58=mysql_result($result,$i,"drive58"); $drive59=mysql_result($result,$i,"drive59"); $drive60=mysql_result($result,$i,"drive60"); $drive61=mysql_result($result,$i,"drive61"); $drive62=mysql_result($result,$i,"drive62"); $drive63=mysql_result($result,$i,"drive63"); $drive64=mysql_result($result,$i,"drive64"); $drive65=mysql_result($result,$i,"drive65"); $drive66=mysql_result($result,$i,"drive66"); $drive67=mysql_result($result,$i,"drive67"); $drive68=mysql_result($result,$i,"drive68"); $drive69=mysql_result($result,$i,"drive69"); $drive70=mysql_result($result,$i,"drive70"); $drive71=mysql_result($result,$i,"drive71"); $drive72=mysql_result($result,$i,"drive72"); $drive73=mysql_result($result,$i,"drive73"); $drive74=mysql_result($result,$i,"drive74"); $drive75=mysql_result($result,$i,"drive75"); $drive76=mysql_result($result,$i,"drive76"); $drive77=mysql_result($result,$i,"drive77"); $drive78=mysql_result($result,$i,"drive78"); $drive79=mysql_result($result,$i,"drive79"); $drive80=mysql_result($result,$i,"drive80"); ?> <div align="center"> <blink>Warning:</blink> Clicking delete will delete this sechedule (no going back once clicked) <table style="width 87%" border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">The Schedule as of: <? echo $date; ?></th> <th><a href="/dominos/admin/delete2.php?urn=<? echo $urn; ?>"><input name='' type='button' value='Delete'/></a></th> <th><a href="../admin/emailit.php"><input type="button" value="Email" /></a></th> <th><a href="../test.php?urn=<? echo $urn; ?>"><input type="button" value="Edit"/></a></th> </tr> </table> <br /> <br /> <input type="text" name="date0" id="date0" value="<? echo $date0; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date1" id="date1" value="<?php echo $date1; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="trans" name="date2" id="date2" value="<?php echo $date2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date3" id="date3" value="<?php echo $date3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date4" id="date4" value="<?php echo $date4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date5" id="date5" value="<?php echo $date5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date6" id="date6" value="<?php echo $date6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date7" id="date7" value="<?php echo $date7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $day; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date1" id="date1" value="<?php echo $day1; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="trans" name="date2" id="date2" value="<?php echo $day2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date3" id="date3" value="<?php echo $day3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date4" id="date4" value="<?php echo $day4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date5" id="date5" value="<?php echo $day5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date6" id="date6" value="<?php echo $day6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date7" id="date7" value="<?php echo $day7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row1; ?>"size="12" maxlength="12" readonly="true"style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row8; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row9; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row10; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row11; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row12; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row13; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row14; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row15; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row16; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row17; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row18; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row19; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row20; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row21; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row22; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row23; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row24; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row25; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row26; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row27; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row28; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row29; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row30; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row31; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row32; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row33; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row34; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row35; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row36; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row37; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row38; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row39; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row40; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row41; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row42; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row43; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row44; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row45; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row46; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row47; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row48; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row50; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row51; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row52; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row53; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row54; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row55; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row56; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row57; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row58; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row59; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row60; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row61; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row62; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row63; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row64; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row65; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive1; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold" /> <input type="text" name="date0" id="date0" value="<? echo $drive2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive8; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive9; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive10; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive11; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive12; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive13; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive14; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive15; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive16; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive17; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive18; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive19; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive20; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive21; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive22; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive23; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive24; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive25; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive26; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive27; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive28; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive29; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive30; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive31; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive32; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive33; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive34; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive35; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive36; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive37; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive38; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive39; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive40; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive41; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive42; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive43; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive44; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive45; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive46; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive47; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive48; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive49; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive50; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive51; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive52; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive53; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive54; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive55; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive56; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive57; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive58; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive59; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive60; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive61; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive62; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive63; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive64; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive65; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive66; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive67; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive68; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive69; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive70; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive71; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive72; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive73; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive74; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive75; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive76; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive77; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive78; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive79; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive80; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <br /> <br /> <br /> <? $i++;} ?> I have an error somewhere in the form as it does not output what I want it too. I know the form itself is working as I have added an echo to see if the form inputs are processed. the code: Code: [Select] <?php $amount = $_POST['amount']; $member = $_POST['member']; $sql = ("SELECT name FROM vtp_members WHERE name=".$member." "); $result = mysql_query($sql); $numrows = mysql_num_rows($result); if($numrows = '1') { while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "You sent ". $amount . " to " . $member . ".<br />"; } } echo " ".$amount." and ".$member." "; ?> It outputs the last echo correct. is there anyone who can see what I'm doing wrong? I have a contact form, and I want to make sure it doesn't send a bunch of duplicates if the page is refreshed after being submitted. Simple way is to make sure this record isn't identical to the one before it: select * from `contacts` where `Name`='$name' and `Phone`='$phone' and `Message`='$message' and `Subject`='$subject' and `Email`='$email' But, that checks against all records. While not likely, this could cause problems, if the same customer came back a month later and put in the same exact contact. Any way I can check it only against the very last record in the database? Something like: and `id`=XX , where XX is one less than the current auto inc id? Hi This should be pretty simple but I can't figure it out.
I want to create and simple forward to different URL based on the user entry.
For example.. If they enter ABC in the box they go to www.11.com if they enter ZXC in the box they go to www.22.com if they enter CCC they go to www.33.com If they enter anything else they get an error message.
Thanks for any help!!
Hi, I got this script which checks a username does not exist, before writing the users registration info to the database. It was working fine, but now for some reason says there is a duplicate username in the database, when there isnt Code: [Select] <?php $password1 = $_POST['password1']; $password2 = $_POST['password2']; if ($password1 != $password2) { echo "Your passwords did not match, please go back and register again"; } else { // Check Passwords Match // Get Posted Variables $username = $_POST['username']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $address = $_POST['address']; $town = $_POST['town']; $county = $_POST['county']; $postcode = $_POST['postcode']; $email = $_POST['email']; $approved = "no"; // MySQL Connection include_once("data/mysql.php"); $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $query = "SELECT COUNT(*) AS count FROM members WHERE username='$username'"; $results = mysql_query($query) or die ("Error reading from database"); $existingUsername = mysql_fetch_array($results); if ($existingUsername['count'] > 0) { echo "I'm sorry our database already contains that username please choose a new username to continue."; } else { $sql = "INSERT INTO members (username, firstname, lastname, address, town, county, postcode, email, password, approved) VALUES ('$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[address]','$_POST[town]','$_POST[county]','$_POST[postcode]','$_POST[email]','$_POST[password2]','$approved')"; mysql_query($sql,$con); ?> <meta http-equiv="REFRESH" content="5;url=../login.html"> <?php } mysql_close($con); } ?> Im sure it is something simple, I just cant see what it is. As always, any help is much appreciated Hi There I am trying to create a page that edit mysql database from a php page. I can get the edit page to show the orginal information but it wont update the data in the mysql database. I am sure I have entered everything right. If anyone could help with this I would greatly appreciated <?php include("dbconnect.php"); if(isset($_POST['submit'])) { // Set global variables to easier names // and prevent sql injection and apostrophe to break the db. $ProductName = mysql_escape_string($_POST['ProductName']); $ProductText = mysql_escape_string($_POST['ProductText']); $ProductImage = mysql_escape_string($_POST['ProductImage']); $ProductPrice = mysql_escape_string($_POST['ProductPrice']); $result = mysql_query("UPDATE Product SET ProductName='$ProductName', ProductText='$ProductText', ProductImage='$ProductImage', ProductPrice='$ProductPrice' WHERE ID='$ID' ",$dbconnect); echo "<b>Thank you! Product UPDATED Successfully!<br>You'll be redirected to View Page after (2) Seconds"; echo "<meta http-equiv=Refresh content=2;url=view.php>"; echo "$ProductName <br> $ProductText <br> $ProductImage <br> $ProductPrice"; } elseif(isset($_GET['ID'])) { $result = mysql_query("SELECT * FROM Product WHERE ID='$_GET[ID]' ",$dbconnect); while($myrow = mysql_fetch_assoc($result)) { $ProductName = $myrow["ProductName"]; $ProductText= $myrow["ProductText"]; $ProductImage = $myrow["ProductImage"]; $ProductPrice = $myrow["ProductPrice"]; ?> <br> <h3>::Edit Product</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" name="ID" value="<? echo $myrow['ID']?>"> Product Name: <input name="ProductName" size="40" maxlength="255" value="<? echo $ProductName; ?>"><br> Product Text: <textarea name="ProductText" rows="7" cols="30"><? echo $ProductText; ?></textarea><br> Product Image: <textarea name="ProductImage" rows="7" cols="30"><? echo $ProductImage; ?></textarea><br> Product Price: <textarea name="ProductPrice" rows="7" cols="30"><? echo $ProductPrice; ?></textarea><br> <input type="submit" name="submit" value="Update Product"> </form> <? }//end of while loop }//end else ?> MySQL returns an error in the form of a number, a state, and a message. Without parsing the message you will not be able to determine what column is duplicated.While parsing the error code, I have also notice that, if you have multiple unique fields as duplicates, only the first duplicate encountered will be returned in the message. This is not very helpful to the end user.
Is there any way to parse the returned error code to reflect all duplicate fields, please see sample code below?
$error=array(); $sql = 'INSERT INTO staff(username, email, phone) VALUES (?, ?, ?)'; $stmt = $conn->stmt_init(); $stmt = $conn->prepare($sql); // bind parameters and insert the details into the database $stmt->bind_param('sss', $username, $email, $phone); $stmt->execute(); if ($stmt->errno == 1062) { $errors[] = "One of the fields is already in use."; } Hi, I was just trying to post form data to MySQL and trying to also post value of logged in user? but that code below doesnt work..Do you see a typo? or is it done some other way?
$uid =$_SESSION[ "uid" ]; $sql = "INSERT INTO Date (uid) VALUES (:uid)"; $query= $conn->prepare( $sql ); $query->execute( array( ':uid'=>$uid) );
$value0 = $_POST['date1']; $value1 = $_POST['date2']; $value2 = $_POST['date3']; $sql = "INSERT INTO Datetable (startdate,enddate, total) VALUES ('$value0','$value1', '$value2')" ; $result = mysqli_query($sql); Hi, I was wondering is it possible to not insert values in MySQL if form entry is left blank? Right now if I dont enter any values in form for my dates than MySQL entry shows 0000-00-00 but I need it not to show anything.
Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: Code: [Select] VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help. |