473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

can't update my database with drop down list from form.

hey guys,please help me out here..

i have made a edit profile form in which i had create a "country" feild with dropdown list...

and i have done the update query and there is no error and dynamically i have type the code to get data from the form into the mysql database table name "register"..but unfortunatly after i click on the button to update it but in the database it displays blank data..

so what is the problem exectly i dint find..
here is the code...

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if (!function_exists("GetSQLValueString")) {
  3. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  4. {
  5.   if (PHP_VERSION < 6) {
  6.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.   }
  8.  
  9.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10.  
  11.   switch ($theType) {
  12.     case "text":
  13.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14.       break;    
  15.     case "long":
  16.     case "int":
  17.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18.       break;
  19.     case "double":
  20.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  21.       break;
  22.     case "date":
  23.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24.       break;
  25.     case "defined":
  26.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27.       break;
  28.   }
  29.   return $theValue;
  30. }
  31. }
  32.  
  33. $editFormAction = $_SERVER['PHP_SELF'];
  34. if (isset($_SERVER['QUERY_STRING'])) {
  35.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  36. }
  37.  
  38. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "profile_update")) {
  39.   $updateSQL = sprintf("UPDATE `register master` SET First_name=%s, Last_name=%s, DOB=%s, contact=%s, city_name=%s, state_name=%s, country_name=%s, address1=%s, address2=%s, profile_photo_path=%s WHERE email_add=%s",
  40.                        GetSQLValueString($_POST['profile_name'], "text"),
  41.                        GetSQLValueString($_POST['profile_lname'], "text"),
  42.                        GetSQLValueString($_POST['profile_dob'], "date"),
  43.                        GetSQLValueString($_POST['profile_phone'], "text"),
  44.                        GetSQLValueString($_POST['profile_city'], "text"),
  45.                        GetSQLValueString($_POST['profile_state'], "text"),
  46.                        GetSQLValueString($_POST['country'], "text"),
  47.                        GetSQLValueString($_POST['address1'], "text"),
  48.                        GetSQLValueString($_POST['address2'], "text"),
  49.                        GetSQLValueString($_POST['upload'], "text"),
  50.                        GetSQLValueString($_POST['profile_email'], "text"));
  51.  
  52.   mysql_select_db($database_conn, $conn);
  53.   $Result1 = mysql_query($updateSQL, $conn) or die(mysql_error());
  54.  
  55.   $updateGoTo = "profile.php";
  56.   if (isset($_SERVER['QUERY_STRING'])) {
  57.     $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  58.     $updateGoTo .= $_SERVER['QUERY_STRING'];
  59.   }
  60.   header(sprintf("Location: %s", $updateGoTo));
  61. }
  62.  
  63. mysql_select_db($database_conn, $conn);
  64. $query_Recordset_reg = "SELECT * FROM `register master`";
  65. $Recordset_reg = mysql_query($query_Recordset_reg, $conn) or die(mysql_error());
  66. $row_Recordset_reg = mysql_fetch_assoc($Recordset_reg);
  67. $totalRows_Recordset_reg = mysql_num_rows($Recordset_reg);
  68. ?>
  69.  
  70.  
  71.   <div class="row cf">
  72.                    <span class="title">Country</span>
  73.                 <select name="country" >
  74.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">India</option>
  75.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">Australia</option>
  76.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">United states</option>
  77.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">Chin</option>
  78.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">Pakistan</option>
  79.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">Japan</option>
  80.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">Srilanka</option>
  81.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">Bangladesh</option>
  82.                   <option value="<?php if (!(strcmp("", $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>">Kenya</option>
  83.                   <?php
  84. do {  
  85. ?>
  86.                   <option value="<?php echo $row_Recordset_reg['country_name']?>"
  87.                  <?php if (!(strcmp($row_Recordset_reg['country_name'], $row_Recordset_reg['country_name']))) {echo "selected=\"selected\"";} ?>>
  88.                  <?php echo $row_Recordset_reg['country_name']?> </option>
  89.                   <?php
  90. } while ($row_Recordset_reg = mysql_fetch_assoc($Recordset_reg));
  91.   $rows = mysql_num_rows($Recordset_reg);
  92.   if($rows > 0) {
  93.       mysql_data_seek($Recordset_reg, 0);
  94.       $row_Recordset_reg = mysql_fetch_assoc($Recordset_reg);
  95.   }
  96. ?>           </select>
  97.             </div>
Dec 9 '12 #1
1 2046
zmbd
5,501 Expert Mod 4TB
First and always is to check your SQL strings.
What I mean by this is that you need to see how they are actually resolving at runtime. You have a serious amount of stuff feeding into the update string at line 39.
See if you can get that to printout for you and post the result back - remember to use the <CODE/> button to format it.
Dec 9 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: kmnotes04 | last post by:
Is it possible to link one drop-down box to another? For example, if a name is chosen from a drop-down list, can another drop-down list then automatically display the person's office as a result of...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
3
by: Mike Collins | last post by:
I'm not feeling too smart right now, but I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. Can someone show...
2
by: Ren | last post by:
Hi all, I am a bit new to PHP and SQL so this may seem like a dumb question. I have already created a drop down list as part of a form which is automatically populated with values taken from a...
3
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include...
5
by: ashok893 | last post by:
I'm using two drop down list ina form. I have generated the first drop down list from MySQL database. When i select an option from first drop down list, i have to generate second drop down list...
0
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in...
3
by: Brad Isaacs | last post by:
ASP.NET 2.0 / SQL Server 2000 db / Visual Basic Code behind On my .aspx page I have added an SQL Datasource that contains the SQL query to retrieve the list for my Drop Down List Box. Using...
2
by: leeperman | last post by:
In Dreaweaver I cannot filter my database results to display only specific data that is retrieved from mulptile drop down list on my search page. The drop down list selections are posted to my...
2
by: ndeeley | last post by:
Hello, I've written a script which returns the admin rights of users in a table - their access level, and their priviledges. The priviledge are returned to a check box and the admin rights to a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.