View Single Post
  #1 (permalink)  
Old 01-15-04, 01:59 PM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
Why do I get a \ in front of '

I'm using a small admin system to insert text to a table (Type : TEXT) and when I use ' symbol I get a \ in ront of it.

Anyway to avoid this.

Do\'s dont\'s



Update Script

PHP Code:

<?php


// Connect to database
$link mysql_connect('localhost','user''password')
    or die(
"Could not connect");
mysql_select_db('select_db')
    or die(
"Could not select database");
    
//Set the Sort method for the sort=name? function - default on name 
if (isset($_GET['club'])) 

     
$club $_GET['club'];

else 

     
$club '';
}

//Query function ( Must be here) 
$result=mysql_query("SELECT * FROM `central` WHERE 1 AND `name` LIKE '$club' LIMIT 0 , 30")
or die(
mysql_error());

$single mysql_fetch_assoc($result);

$submitted  date("d/m/Y H:i:s");

if (!isset(
$_POST['submit'])) { 
echo
'<BODY bgColor=#155271 leftMargin=0 topMargin=0 rightMargin=0 bottomMargin=0 marginwidth="0" marginheight="0" onLoad="MM_preloadImages(\'guestlistOver.jpg\',\'mapOver.jpg\',\'galleryOver.jpg\',\'writeOver.jpg\')">
<table width="100%" height="544" border="0" cellpadding="0" cellspacing="0" id="AutoNumber7" style="border-collapse: collapse">
  <tr> 
    <td width="380" height="544" valign="top" bordercolor="#FFFFFF">
<table width="400" height="100%" border="0" cellpadding="0" cellspacing="0" id="AutoNumber8" style="border-collapse: collapse">
        <tr> 
          <td width="100%" valign="top"> <TABLE width="98%" border=0 cellPadding=0 cellSpacing=0>
              <TBODY>
                <TR> 
                  <TD width="140"><img src="home/comments.jpg" height="20"></TD>
                  <TD width="206">
<div align="left"></div>
                    </TD>
                  <TD width="52"><div align="right"><a href="javascript:history.back(1)" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Back\',\'\',\'home/backOver.gif\',1)"><img src="home/back.gif" alt="< Back" name="Back" width="40" height="20" border="0"></a></div></TD>
                </TR>
                <TR> 
                  <TD height="2" colspan="3" background="home/line.gif"></TD>
                </TR>
              </TBODY>
            </TABLE>
            <TABLE cellSpacing=0 cellPadding=0 width="400" border=0>
              <TBODY>
                <TR> 
                  <TD colSpan=2 height=6></TD>
                </TR>
                <TR> 
                  <TD width=114 height="72"><img height=73 alt="" src="clubs/'
,$single['thumb'],'" width=109 border=0></TD>
                  <TD rowspan="6" vAlign=top> 
                  
                  <TABLE width="100%" height="173" border=0 cellPadding=0 cellSpacing=0>
                      <TBODY>
                        <TR> 
                          <TD width=6><IMG height=8 alt="" src="home/bdr_leftcr.gif" width=6 border=0></TD>
                          <TD 
                            height=6 colspan="4" background=home/bdr_top.gif></TD>
                          <TD width=6><IMG height=8 alt="" src="home/bdr_rightcr.gif" width=6 border=0></TD>
                        </TR>
                        <TR> 
                          <TD width=6 height="128" rowspan="2" background="home/bdr_leftside.gif"></TD>
                          <TD height="127" colspan="4" vAlign=top bgColor=#0F364A class="mainText"><p>
                            <span class="mainTextBig">'
,$single['name'],'<br>
                            ('
,$single['address'],')</span><br>
                            <span class="mainText"><br>
                            '
,$single['description'],'</span></p>
                          </TD>
                          <TD width=6 rowspan="2" background=home/bdr_rightside.gif></TD>
                        </TR>
                        <TR> 
                          <TD width="31" height="19" vAlign=top bgColor=#0F364A class="mainTextBig">Tube:</TD>
                          <TD width="105" vAlign=top bgColor=#0F364A class="mainText">'
,$single['tube'],'</TD>
                          <TD width="53" vAlign=top bgColor=#0F364A class="mainTextBig">Times:</TD>
                          <TD width="85" vAlign=top bgColor=#0F364A class="mainText">'
,$single['times'],'</TD>
                        </TR>
                        <TR> 
                          <TD height="19" background="home/bdr_leftside.gif"><IMG height=20 alt="" src="home/bdr_leftcr_bt2.gif" width=6 border=0></TD>
                          <TD height="19" vAlign=top background="home/bdr_bottom.gif" bgColor=#0F364A class="mainTextBig">Tel:</TD>
                          <TD vAlign=top background="home/bdr_bottom.gif" bgColor=#0F364A class="mainText">'
,$single['tel'],'</TD>
                          <TD vAlign=top background="home/bdr_bottom.gif" bgColor=#0F364A class="mainTextBig">Capacity:</TD>
                          <TD vAlign=top background="home/bdr_bottom.gif" bgColor=#0F364A class="mainText">'
,$single['capacity'],'</TD>
                          <TD background=home/bdr_rightside.gif><IMG height=20 alt="" src="home/bdr_rightcr_bt2.gif" width=6 border=0></TD>
                        </TR>
                      </TBODY>
                    </TABLE>
                    <TABLE width="100%" border=0 align="left" cellPadding=0 cellSpacing=0>
                      <TBODY>
                      </TBODY>
                    </TABLE></TD>
                </TR>
                <TR> 
                  <TD height="20"><img src="rate/'
,$single['rate'],'.gif" alt="',$single['rate'],' Rating" width="109" height="20"></TD>
                </TR>
                <TR> 
                  <TD height="20"><a href="http://www.selectguestlist.com/index/clubsguestlist.php?club='
,$single['name'],'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Guestlist\',\'\',\'guestlistOver.jpg\',1)"><img src="guestlist.jpg" alt="Guestlist" name="Guestlist" width="109" height="20" border="0"></a></TD>
                </TR>
                <TR> 
                  <TD height="20"><a href="'
,$single['map'],'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Map\',\'\',\'mapOver.jpg\',1)"><img src="map.jpg" alt="Map" name="Map" width="109" height="20" border="0"></a></TD>
                </TR>
                <TR> 
                  <TD height="5"><a href="'
,$single['gallery'],'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Gallery\',\'\',\'galleryOver.jpg\',1)"><img src="gallery.jpg" alt="Gallery" name="Gallery" width="109" height="20" border="0"></a></TD>
                </TR>
                <TR>
                  <TD height="5"><img src="blank.jpg" width="109" height="20"></TD>
                </TR>
                <TR> 
                  <TD height="2"></TD>
                </TR>
              </TBODY>
            </TABLE>
            
            
            <TABLE width="400" border=0 cellPadding=0 cellSpacing=0">
              <TBODY>
                <TR> 
                  <TD colSpan=2 height=6></TD>
                </TR>
                <TR> 
                  <TD colspan="2"><TABLE cellSpacing=0 cellPadding=0 width="408" border=0>
                      <TBODY>
                        <TR> </TR>
                        <TR> 
                          <TD width="357" vAlign=top> <TABLE width="96%" height="131" 
border=0 cellPadding=0 cellSpacing=0>
                              <TBODY>
                                <TR> 
                                  <TD width=6><IMG height=8 alt="" 
                              src="home/bdr_leftcr.gif" width=6 
                            border=0></TD>
                                  <TD width="100%" background=home/bdr_top.gif 
                            height=6></TD>
                                  <TD width=6><IMG height=8 alt="" 
                              src="home/bdr_rightcr.gif" width=6 
                            border=0></TD>
                                </TR>
                                <TR> 
                                  <TD width=6 background="home/bdr_leftside.gif"></TD>
                                  <TD width="100%" vAlign=top bgColor=#0F364A class="mainText"> 
                                    <form name="guestlist" method="POST" action="'
.$_SERVER['PHP_SELF'].'">
                                      <TABLE width="389" height="179" border=0 cellPadding=3 cellSpacing=2 bgcolor="#0F364A">
                                        <TBODY>
                                          <TR> 
                                            <TD width="56" height="23" class=mainText><b>Full 
                                              Name:</b></TD>
                                            <TD colspan="3" class=frmInput> <INPUT name="authorName" type="text" class=mainFormBox id="authorName" style="WIDTH: 315px"></TD>
                                          </TR>
                                          <TR> 
                                            <TD width="56" height="30" class=mainText><B>Email 
                                              Address:</B></TD>
                                            <TD colspan="3" class=frmInput> <INPUT name="email" type="text" class=mainFormBox id="email" style="WIDTH: 315px"></TD>
                                          </TR>
                                          <TR> 
                                            <TD width="56" height="26" class=mainText><strong>Location:</strong></TD>
                                            <TD width="127"><INPUT name="location" type="text" class=mainFormBox id="location" style="WIDTH: 120px"></TD>
                                            <TD width="39" class=mainText><strong>Rating:</strong></TD>
                                            <TD width="144" class=frmInput> <div align="right"> 
                                                <select name="authorRating" class="mainFormBox" id="authorRating" style="WIDTH: 120px">
                                                  <option value="" selected>Rating</option>
                                                  <option>Bad</option>
                                                  <option>Poor</option>
                                                  <option>OK</option>
                                                  <option>Good</option>
                                                  <option>Excellent</option>
                                                </select>
                                              </div></TD>
                                          </TR>
                                          <TR> 
                                            <TD width="56" height="30" class=mainText><b>Comments:</b></TD>
                                            <TD colspan="3" class=frmInput><FONT size=1> 
                                              <TEXTAREA class=mainFormBox onkeydown=textCounter(this.form.comments,this.form.remLen,450); onkeyup=textCounter(this.form.comments,this.form.remLen,450); name=comments rows=4 wrap=VIRTUAL cols=48></TEXTAREA>
                                              </FONT> </TD>
                                          </TR>
                                          <TR> 
                                            <TD class=frmDescription width="56">&nbsp;</TD>
                                            <TD class=frmInput> <div align="left"> 
                                                <p><FONT size=1> 
                                                  <INPUT class=mainFormBox readOnly maxLength=3 size=2 value=450 name=remLen>
                                                  </FONT></p>
                                              </div></TD>
                                            <TD colspan="2" class=frmInput> <div align="right"> 
                                                <input type="hidden" name="idClub" value="'
,$single['name'],'">
                                                <input type="hidden" name="submitted" value="' 
.$submitted'">
                                                <input type="hidden" name="submit" value="done">
                                                <input type=image name="submit2" value="Submit" height=20 width=109 src="submit.jpg" align=Submit >
                                              </div></TD>
                                          </TR>
                                        </TBODY>
                                      </TABLE>
                                    </form></TD>
                                  <TD width=6 
                              background=home/bdr_rightside.gif>&nbsp;</TD>
                                </TR>
                              </TBODY>
                            </TABLE>
                            <TABLE width="401" border=0 cellPadding=0 cellSpacing=0>
                              <TBODY>
                                <TR> 
                                  <TD width=6><IMG height=24 alt="" 
                              src="home/bdr_leftcr_bt.gif" width=6 
                              border=0></TD>
                                  <TD height=24 
                            background=home/bdr_bottom.gif>&nbsp;</TD>
                                  <TD width=6><IMG height=24 alt="" 
                              src="home/bdr_rightcr_bt.gif" width=6 
                              border=0></TD>
                                </TR>
                              </TBODY>
                            </TABLE></TD>
                        </TR>
                        <TR> 
                          <TD></TD>
                        </TR>
                      </TBODY>
                    </TABLE></TD>
                </TR>
                <TR> 
                  <TD width="114" height="2"></TD>
                </TR>
              </TBODY>
            </TABLE>
            
            </td>
        </tr>
      </table>
      
    </td>
    <td width="136" valign="top" bordercolor="#FFFFFF">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber12">
        <tr> 
          <td width="100%" align="center">'
;
          
?>
          
          <script type="text/javascript"><!--
    google_ad_client = "pub-332977970435434533";
    google_ad_width = 120;
    google_ad_height = 600;
    google_ad_format = "120x600_as";
    google_color_border = "155271";
    google_color_bg = "0F364A";
    google_color_link = "4CCAF4";
    google_color_url = "2C2C39";
    google_color_text = "FFFFFF";
    //--></script>
    <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    
<?PHP
    
echo '    </td>
        </tr>
        <tr> 
          <td align="center">&nbsp; </td>
        </tr>
      </table>
    </td>
  </tr>
</table>'
;

    } else {
    
$idClub=trim(addslashes($_POST['idClub']));
$submitted=trim(addslashes($_POST['submitted']));    

$comments=trim(addslashes($_POST['comments']));
$authorName=trim(addslashes($_POST['authorName']));
$location=trim(addslashes($_POST['location']));
$authorRating=trim(addslashes($_POST['authorRating']));

$insert=mysql_query("INSERT INTO comments (idClub, comments, authorName, location, authorRating, submitted) VALUES ('$idClub', '$comments', '$authorName', '$location', '$authorRating', '$submitted')")or 
die(
'couldn\'t Insert record into Comments database :'.mysql_error());

 echo 
'<meta http-equiv=\'refresh\' content=\'1; url=http://www.selectguestlist.com/index/comments.php?club=' .$idClub'\'>'


?>
Reply With Quote