943,703 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 377
  • PHP RSS
Jul 29th, 2009
0

how do i get rid of the "/"?

Expand Post »
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 .


PHP Syntax (Toggle Plain Text)
  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>
Similar Threads
k2k
Reputation Points: 15
Solved Threads: 1
Posting Whiz
k2k is offline Offline
351 posts
since Nov 2007
Jul 29th, 2009
0

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

<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.
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 728
Bite my shiny metal ass!
pritaeas is offline Offline
4,166 posts
since Jul 2006
Jul 29th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by pritaeas ...
<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
k2k
Reputation Points: 15
Solved Threads: 1
Posting Whiz
k2k is offline Offline
351 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How to Store XAMPP in Drive D in Windows XP
Next Thread in PHP Forum Timeline: PHP and HTML Syntax





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC