php - My sites INSERT and UPDATE script has ceased working -


i complete newb php malarkey concerned, have picked few basics , many more bad habits.

the problem have insert script , update scripts have ceased working on friday, last time know insert worked thursday items added pretty daily without problems. have done added 2 fields in database 'salesperson' , 'live_date' , amended scripts accordingly, when realized had stopped working re-uploaded original files , still wasn't working, don't know if coincidence or i've broken something.

i can't life of me see errors in script know, (actually wish re-phrase that, can't see errors cause problem, i'm sure there plenty of errors in ;-)

i appreciate if 1 of experts take peek me before yank out grey hair have remaining.

many in advance. ian.

insert script:

<?php  //connect mysql database include"../scripts/connect_to_mysql.php";  if (!get_magic_quotes_gpc()) {  $meta_desc=addslashes($_post['meta_desc']); $sku=$_post['sku']; $salesperson=$_post['salesperson']; $business_name=addslashes($_post['business_name']); $address=$_post['address']; $package=addslashes($_post['package']);  $contact_name=addslashes($_post['contact_name']); $description=addslashes($_post['description']); $phone=$_post['phone']; $e_mail=$_post['e_mail']; $short_web=$_post['short_web']; $weblink=$_post['weblink']; $facebook=$_post['facebook']; $first_ad=$_post['first_ad']; $main_menu=$_post['main_menu']; $category=$_post['category']; $sub_category=$_post['sub_category']; $niche_category=$_post['niche_category']; $display_ad=$_post['display_ad']; $live_date=addslashes($_post['live_date']); }  $sql=mysql_query( "insert business_list (id, meta_desc, sku, salesperson, business_name, address, package, contact_name, description, phone, e_mail, short_web, weblink, facebook, first_ad, main_menu, category, sub_category, niche_category, display_ad, live_date) values ('null', '$meta_desc', 'null', '$salesperson', '$business_name', '$address', '$package', '$contact_name', '$description', '$phone', '$e_mail', '$short_web', '$weblink', '$facebook', '$first_ad', '$main_menu', '$category', '$sub_category', '$niche_category', '$display_ad', '$live_date')");   $lastid=mysql_insert_id(); $sql=mysql_query ($sql) or die ('<p></p><p></p>database updated  information relating to:<strong> ' . $business_name . ' </strong>,  <p>use id ad image:<strong> ' . $lastid . ' </strong><form action="set_sku.php" method="post" enctype="multipart/form-data" name="set_sku"> <p>now need update sku in database</p> <label>input id here update sku , continue add images</label> <input name="sku" type="text" maxlength="7" /> <input type="submit" value="update sku" /> </form> </p>'); mysql_close() ?> 

update script:

<?php  include"../scripts/connect_to_mysql.php";  if (!get_magic_quotes_gpc()) {  $ud_id=$_post['ud_id']; $ud_sku=$_post['ud_sku']; $ud_live_date=addslashes($_post['ud_live_date']); $ud_business_name=addslashes($_post['ud_business_name']); $ud_address=addslashes($_post['ud_address']); $ud_package=addslashes($_post['ud_package']); $ud_contact_name=addslashes($_post['ud_contact_name']); $ud_description=addslashes($_post['ud_description']); $ud_meta_desc=addslashes($_post['ud_meta_desc']); $ud_phone=$_post['ud_phone']; $ud_e_mail=$_post['ud_e_mail']; $ud_short_web=$_post['ud_short_web']; $ud_weblink=$_post['ud_weblink']; $ud_facebook=$_post['ud_facebook']; $ud_first_ad=$_post['ud_first_ad']; $ud_category=$_post['ud_category']; $ud_sub_category=$_post['ud_sub_category']; $ud_niche_category=$_post['ud_niche_category']; $ud_display_ad=$_post['ud_display_ad']; $ud_salesperson=$_post['ud_salesperson']; }  $query="update business_list set sku='$ud_sku', live_date='$ud_live_date', business_name='$ud_business_name', address='$ud_address', package='$ud_package', contact_name='$ud_contact_name', description='$ud_description', meta_desc='$ud_meta_desc', phone='$ud_phone', e_mail='$ud_e_mail', short_web='$ud_short_web', weblink='$ud_weblink', facebook='$ud_facebook', first_ad='$ud_first_ad', main_menu='$ud_main_menu', category='$ud_category', sub_category='$ud_sub_category', niche_category='$ud_niche_category', display_ad='$ud_display_ad', salesperson='$ud_salesperson' id='$ud_id'";  mysql_query($query);  echo "record updated"; mysql_close(); ?>   <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="robots" content="noindex, nofollow"> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>slbd - admin</title> <link rel="stylesheet" href="../stylesheets/style.css" type="text/css" media="screen" /> </head>  <body>  <?php include_once("../templates/template_header.php"); ?>  <h1> <?php echo "record updated"; ?></h1>  <div id="contact" class="request"> <a href="log_out.php">[log out]</a> | <a href="reports_asc.php"> [reports]</a>  <table width="100%" border="0" cellpadding="40"> <tr><strong> <form action="admin.php" method="get" name="id">     <td align="center">     <input type="submit" value="add advert" /> </td> </form>    <form action="imageadmin.php">     <td align="center">    <input type="submit" value="add or update image" /> </td> </form>   <form action="admin_update.php" method="get" name="id">  <td align="center">  <label>update ad id?</label><br /><br /> <input name="id" type="text" size="5" maxlength="7">   <br /><br /> <input type="submit" value="update advert" /> </td>   </form>   </strong>  </tr>  </table>  </div> <br /> <?php include_once("../templates/template_footer.php"); ?> </body> </html> 

the connect script works fine because:

  • the site displays correctly , uses same script
  • the update command collects data, won't update

your using deprecated mysql. lets convert work mysqli

insert page:

<?php   /* we'll start of establishing connection */  $connection=mysqli_connect("host","username","password","database");  if(mysqli_connect_errno()){  echo "error".mysqli_connect_error(); }  if(isset($_post['skusubmit'])){ /* if button clicked */  $meta_desc=addslashes($_post['meta_desc']); $sku=$_post['sku']; $salesperson=$_post['salesperson']; $business_name=addslashes($_post['business_name']); $address=$_post['address']; $package=addslashes($_post['package']);  $contact_name=addslashes($_post['contact_name']); $description=addslashes($_post['description']); $phone=$_post['phone']; $e_mail=$_post['e_mail']; $short_web=$_post['short_web']; $weblink=$_post['weblink']; $facebook=$_post['facebook']; $first_ad=$_post['first_ad']; $main_menu=$_post['main_menu']; $category=$_post['category']; $sub_category=$_post['sub_category']; $niche_category=$_post['niche_category']; $display_ad=$_post['display_ad']; $live_date=addslashes($_post['live_date']);  /* start insert query */  mysqli_query($connection,"insert business_list (id, meta_desc, sku, salesperson, business_name, address, package, contact_name, description, phone, e_mail, short_web, weblink, facebook, first_ad, main_menu, category, sub_category, niche_category, display_ad, live_date) values ('null', '$meta_desc', 'null', '$salesperson', '$business_name', '$address', '$package', '$contact_name', '$description', '$phone', '$e_mail', '$short_web', '$weblink', '$facebook', '$first_ad', '$main_menu', '$category', '$sub_category', '$niche_category', '$display_ad', '$live_date')");  echo "database updated  information relating to: <strong>". $business_name;  } /* end of isset */  /* submit on */ echo "<form action='' method='post' enctype='multipart/form-data'>"; echo "<p>now need update sku in database</p>"; echo "<label>input id here update sku , continue add images</label>"; echo "<input name='sku' type='text' maxlength='7' />"; /* please continue here other input fields needed */ echo "<input type='submit' value='update sku' name='skusubmit' />"; echo "</form>";  ?> 

here's update page

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="robots" content="noindex, nofollow"> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>slbd - admin</title> <link rel="stylesheet" href="../stylesheets/style.css" type="text/css" media="screen" /> </head>  <body>  <?php       /* we'll start of establishing connection */      $connection=mysqli_connect("host","username","password","database");      if(mysqli_connect_errno()){      echo "error".mysqli_connect_error();     }  if (isset($_post['updatesubmit'])) {   $ud_id=$_post['ud_id']; $ud_sku=$_post['ud_sku']; $ud_live_date=addslashes($_post['ud_live_date']); $ud_business_name=addslashes($_post['ud_business_name']); $ud_address=addslashes($_post['ud_address']); $ud_package=addslashes($_post['ud_package']); $ud_contact_name=addslashes($_post['ud_contact_name']); $ud_description=addslashes($_post['ud_description']); $ud_meta_desc=addslashes($_post['ud_meta_desc']); $ud_phone=$_post['ud_phone']; $ud_e_mail=$_post['ud_e_mail']; $ud_short_web=$_post['ud_short_web']; $ud_weblink=$_post['ud_weblink']; $ud_facebook=$_post['ud_facebook']; $ud_first_ad=$_post['ud_first_ad']; $ud_category=$_post['ud_category']; $ud_sub_category=$_post['ud_sub_category']; $ud_niche_category=$_post['ud_niche_category']; $ud_display_ad=$_post['ud_display_ad']; $ud_salesperson=$_post['ud_salesperson'];  mysqli_query($connection,"update business_list set sku='$ud_sku', live_date='$ud_live_date', business_name='$ud_business_name', address='$ud_address', package='$ud_package', contact_name='$ud_contact_name', description='$ud_description', meta_desc='$ud_meta_desc', phone='$ud_phone', e_mail='$ud_e_mail', short_web='$ud_short_web', weblink='$ud_weblink', facebook='$ud_facebook', first_ad='$ud_first_ad', main_menu='$ud_main_menu', category='$ud_category', sub_category='$ud_sub_category', niche_category='$ud_niche_category', display_ad='$ud_display_ad', salesperson='$ud_salesperson' id='$ud_id'");  echo "record updated";  } /* end of isset submit */  include_once("../templates/template_header.php"); ?>  <h1> <?php echo "record update"; ?></h1>  <div id="contact" class="request"> <a href="log_out.php">[log out]</a> | <a href="reports_asc.php"> [reports]</a>  <table width="100%" border="0" cellpadding="40"> <tr><strong> <form action="" method="get" name="id">  <td align="center">  <label>update ad id?</label><br /><br /> <input name="id" type="text" size="5" maxlength="7">   <br /><br /> <?php /* add here other textbox. assign corresponding name them */ ?> <input type="submit" value="update advert" name="updatesubmit"/> </td>   </form> </strong>  </tr>  </table>  </div> <br /> <?php include_once("../templates/template_footer.php"); ?> </body> </html> 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -