Jump to content


Photo

closing a DB


  • Please log in to reply
4 replies to this topic

#1 opel

opel
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 26 September 2006 - 08:21 PM

I am learning how to use PHP by hand coding everything.

my code below works to pull out a list of web links from the database and display them in a table. My question is should I have a DB close tag somewhere to close the DB for security reasons?

Here is my code:

<?php
include ('connections/config.php');
include ('connections/dbconn.php');


$query  = "SELECT link_id, link_title, link_desc, category_id, link_display FROM tbl_links WHERE link_display='Yes'";
$result = mysql_query($query) or die("error querying database");
$i = 0;
while($result_ar = mysql_fetch_assoc($result)){
?>
<tr <?php if($i%2 == 1){ echo "class='tablerow2'"; }else{echo "class='tablerow1'";}?>>
<td>
<?php echo $result_ar['link_title']; ?></td>
<td>
<?php echo $result_ar['category_id']; ?>
</td>
<td class="button">
<a href="edit_link_detail.php?ID=<?php echo $result_ar['website']; ?>" title="Edit This Link">Edit</a>
</td>
<td class="button">
<a href="delete_link.php?ID=<?php echo $result_ar['website']; ?>" title="Delete This Link">Delete</a>
</td>
</tr>
<?php
$i+=1;

                    
}?>
</table>


#2 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 26 September 2006 - 08:29 PM

Nah, the script runs and connects to the database before the user can access it, just make sure anytime you take input you addslashes() and your fine.

#3 opel

opel
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 26 September 2006 - 09:02 PM

sorry can you explain what you mean by adding slashes?

#4 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 26 September 2006 - 09:07 PM

I'm quite sure you don't need to close it or anything, and i'm not sure it's possible either. All your php is server side, so nobody can get your passwords unless they have access to your server.

(Someone please correct me if i'm wrong)

#5 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 26 September 2006 - 09:09 PM

php.net/addslashes

$form_input = addslashes($_POST["form_name"]);




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users