Results 1 to 4 of 4

Thread: Hiding Connection String, do I just change file permissions?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    80

    Hiding Connection String, do I just change file permissions?

    Hi,

    I'm planning on using a script like this to display a table from my database.

    What I want to know is do I simply change the permissions so the file is executable only? I don't want them to be able to read the code of the php file, but they must be able to read what it outputs.

    If it is the permission settings what permissions should I use in this case?

    thx all help is appreciated

    Code:
    <?php
    $con = mysql_connect("localhost","peter","abc123");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("my_db", $con);
    
    $result = mysql_query("SELECT * FROM Persons");
    
    echo "<table border='1'>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    </tr>";
    
    while($row = mysql_fetch_array($result))
      {
      echo "<tr>";
      echo "<td>" . $row['FirstName'] . "</td>";
      echo "<td>" . $row['LastName'] . "</td>";
      echo "</tr>";
      }
    echo "</table>";
    
    mysql_close($con);
    ?>

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Hiding Connection String, do I just change file permissions?

    If I'm correctly understanding what you want, then no special permissions are needed. When viewed in a browser, users will only be able to see what PHP has output, nothing else. If they use their browser's "view source" feature, all they'll see is the HTML that makes up your table.

  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Hiding Connection String, do I just change file permissions?

    I believe that you only have to change the permission in the database if a user going to have access to certain functions such as add, delete, etc inside the database.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Hiding Connection String, do I just change file permissions?

    As SambaNeko said, you dont have to worry about the world seeing your code. It is server side code, so it is all processed on the server, then the HTML is set to the browser.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width