Jump to content

Recommended Posts

First I spent several hours wondering whats wrong with my code,  before geting answer on this forum that PHP5 doesn't accept shorthand <? but <?php...

Now I am trying to access mysql database on my local server, as I always did before downloading latest version of XAMPP.

Message I got is:

Access forbidden!

 

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

 

If you think this is a server error, please contact the webmaster.

Error 403

Why can I access database with the usual:

$con = mysql_connect ('localhost','root','');

$db = mysql_select_db ('codes');

please help.

Link to comment
https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/
Share on other sites

A HTTP 403 status code (or any other HTTP status code) and error page that your browser displays has nothing to do with the database code in your file, it means that the URL of the page you requested returned that error. You would need to determine why the web server returned that status code for the URL that you requested.

The fault was in using form action = "<? $PHP_SELF; ?>"

 

When i changed it to form action = "nameofthefile.php" it worked again.

It seems strange to me to abolish such a useful way of posting the page on itself that allows you to change the documents name, and it still works.

$PHP_SELF was depreciated when register_globals were turned off by default in php4.2 in the year 2002. You would use $_SERVER['PHP_SELF'] in place of $PHP_SELF, but an empty action="" attribute refers to the same page anyway.

At the point where you want error_reporting to be set to that value.

 

I recommend setting error_reporting to E_ALL and display_errors to ON in your php.ini (stop and start your web server to get any change made to php.ini to take effect and verify that the values were actually changed using a phpinfo() statement) so that fatal parse errors are also reported. Setting them in your script won't help with fatal parse errors because your script will never run to cause those settings to be turned on.

I am not sure where php.in file is in XAMPP, I am a novice still.

 

But more important is this, below code worked fine and now dispalys only $line[' '] in rows in my table that I used to get my codes from the database.

 

else {

$con = mysql_connect ('localhost','root','');

$db = mysql_select_db ('kodovi');

echo !$db;

$sql = "select * from $selectTable where id = $id ";

echo $sql."<br><br>";

$results = mysql_query($sql);

$line = mysql_fetch_array ($results);

?>

<!--  tabela sa kodom -->

<form action="" method="get">

<input type="hidden" name="id" value="<? echo $id; ?>" />

<input type="hidden" name="selectTable" value="<? echo $selectTable; ?>"  />

datum:<input type="text" name="datum" value="<? echo $line['datum']; ?>" /><br /><br />

naziv:<input type="text" size="60" name="naziv" value="<? echo $line['naziv']; ?>"  /><br /><br />

kod:<br /><textarea cols= "120" rows="90" name="kod"  />

<!--  <? echo $line['kod']; ?>  -->

</textarea><br /><br />

resource:<input type="text" name = "resource" size = "100" value="<? echo $line['resource']; ?>"  /><br /><br />

<input type="submit" name="update" value="update" />

<input type="submit" class="crvena" name="delete" value="delete" /><br /><br /><br />

</form>

<?php

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.