how do i get rid of the "/"?

Thread Solved

Join Date: Nov 2007
Posts: 227
Reputation: k2k is an unknown quantity at this point 
Solved Threads: 0
k2k k2k is offline Offline
Posting Whiz in Training

how do i get rid of the "/"?

 
0
  #1
Jul 29th, 2009
hi,
if i left a field blank in my table. when i tried to retrieve all the info out to the form. the text box supposed to have blank (because the corresponding field in the table is blank) appear a "/" ... i have tried to use trim() ... stripslashes() and none works so far. please help .


  1. <?php
  2. require_once('auth.php');
  3. require_once('config.php');
  4.  
  5. $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
  6. if(!$link)
  7. {
  8. die('Failed to connect to server: ' . mysql_error());
  9. }
  10.  
  11. //Select database
  12. $db = mysql_select_db(DB_DATABASE);
  13. if(!$db)
  14. {
  15. die("Unable to select database");
  16. }
  17.  
  18. $cid = $_SESSION['SESS_CUSTOMER_ID'];
  19.  
  20. function clean($str)
  21. {
  22. $str = @trim($str);
  23.  
  24. while(strchr($str, '\\'))
  25. {
  26. $str = stripslashes($str);
  27. }
  28.  
  29. if(get_magic_quotes_gpc())
  30. {
  31. $str = stripslashes($str);
  32. }
  33. return mysql_real_escape_string($str);
  34. }
  35.  
  36. $qry="SELECT fname, lname, email, streetAddress,zip_id, passwd FROM customer WHERE customer_id='$cid'";
  37. $cResult=mysql_fetch_array(mysql_query($qry));
  38.  
  39. /*
  40. $fn= "$cResult[0]";
  41. $ln= "$cResult[1]";
  42. $email= "$cResult[2]";
  43. $street= "$cResult[3]";
  44. $zipid= "$cResult[4]";
  45. $passwd = "$cResult[5]";
  46. */
  47. $fn= clean($cResult[0]);
  48. $ln= clean($cResult[1]);
  49. $email= clean($cResult[2]);
  50. $street= "$cResult[3]";
  51. $zipid= "$cResult[4]";
  52. $passwd = "$cResult[5]";
  53.  
  54. $qryZip ="SELECT zip, city, state_id FROM zipcode WHERE zip_id = '$zipid'";
  55. $zResult = mysql_fetch_array(mysql_query($qryZip));
  56.  
  57. $zip="$zResult[0]";
  58. $city="$zResult[1]";
  59. $stateid = "$zResult[2]";
  60.  
  61. $qryState = "SELECT state FROM state WHERE state_id = '$stateid'";
  62. $sResult = mysql_fetch_array(mysql_query($qryState));
  63. $state = "$sResult[0]";
  64. ?>
  65.  
  66. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  67. <html xmlns="http://www.w3.org/1999/xhtml">
  68. <head>
  69. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  70. <title>Welcome to the member area</title>
  71. <link rel="stylesheet" type="text/css" href="../style.css"/>
  72. <script src="../validate.js"></script>
  73. </head>
  74. <style type="text/css">
  75.  
  76. #menu
  77. {
  78. position: relative;
  79. width: 800px;
  80. height: 100px;
  81. border: none;
  82. background-image:url(../images/menuBG.png);
  83. }
  84.  
  85. #middleBoard
  86. {
  87. position: relative;
  88. width: 800px;
  89. height: 500px;
  90. border: none;
  91.  
  92. }
  93.  
  94.  
  95.  
  96.  
  97. </style>
  98.  
  99. <body>
  100.  
  101. <div class="bxcen" id="menu">
  102. <br />
  103. <table bgcolor="#666666", bordercolor="#666666", align="center">
  104. <tr height="30">
  105. <td class="menu" width="80">
  106. <a href="../index.htm">Home</a>
  107. </td>
  108.  
  109. <td class="menu" width="80">
  110. <a href="../product.htm">Products</a>
  111. </td>
  112.  
  113. <td class="menu" width="80">
  114. <a href="../registry.htm">Register</a>
  115. </td>
  116.  
  117. <td class="menu" width="80">
  118. <a href="logout.php" >Logout</a>
  119. </td>
  120.  
  121. <td class="menu" width="80">
  122. <a href="../contact.htm">Contact us </a>
  123. </td>
  124.  
  125. <td class="menu" width="80">
  126. <a href="../faq1.htm">FAQ</a>
  127. </td>
  128.  
  129. <td class="menu" width="80">
  130. <a href="newPromotion.php">Promotion</a>
  131. </td>
  132.  
  133. </tr>
  134. </table>
  135. </div>
  136.  
  137. <div id="middleBoard" class="bxcen">
  138. <center><p style="color:#00CC00">You are logged in.</p></center>
  139.  
  140. <form id="editPanel" name="editPanel" method="post" action="member-index-exec.php" >
  141. <p>First Name: <input type="text" name="fn" value=<?php print($fn);?> /></p>
  142. <p>Last Name: <input type="text" name="ln" value=<?php print($ln);?> /></p>
  143. <p>Email: <input type="text" name="email" value=<?php print($email);?> /></p>
  144. <p>Address: <input type="text" name="street" value="<?php print($street);?>" /></p>
  145. <p>City: <input type="text" name="city" value=<?php print($city);?> /></p>
  146. <p>State: <input type="text" name="state" value=<?php print($state);?> /></p>
  147. <p>Zip: <input type="text" name="zip" value=<?php print($zip);?> /></p>
  148. <p>Password: <input type="password" name="pass" value=<?php print($passwd);?> /> (You may change your password by entering a new one)</p>
  149. <p>Password Confirmation: <input type="password" name="passConfirm"/>(Please enter your new password again)</p>
  150. <p><input type="submit" value="Save" /></p>
  151. </form>
  152. </html>
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 856
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 139
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: how do i get rid of the "/"?

 
0
  #2
Jul 29th, 2009
<input type="text" name="state" value=<?php print($state);?> />
i think the problem here is that the " are missing around the value. Try:

<input type="text" name="state" value="<?php print($state);?>" />
Last edited by pritaeas; Jul 29th, 2009 at 4:12 am.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 227
Reputation: k2k is an unknown quantity at this point 
Solved Threads: 0
k2k k2k is offline Offline
Posting Whiz in Training

Re: how do i get rid of the "/"?

 
0
  #3
Jul 29th, 2009
Originally Posted by pritaeas View Post
<input type="text" name="state" value=<?php print($state);?> />
i think the problem here is that the " are missing around the value. Try:

<input type="text" name="state" value="<?php print($state);?>" />

that's good catch. Thanks much
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC