zoran Posted August 23, 2009 Share Posted August 23, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2009 Share Posted August 23, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904706 Share on other sites More sharing options...
zoran Posted August 23, 2009 Author Share Posted August 23, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904709 Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2009 Share Posted August 23, 2009 $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. Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904714 Share on other sites More sharing options...
zoran Posted August 23, 2009 Author Share Posted August 23, 2009 In which part of the document do you put function error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904717 Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2009 Share Posted August 23, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904720 Share on other sites More sharing options...
zoran Posted August 23, 2009 Author Share Posted August 23, 2009 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904731 Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2009 Share Posted August 23, 2009 The phpinfo(); output shows the php.ini that php using as the - Loaded Configuration File All the <? tags need to be changed to <?php and if you are using <?=, those need to be changed to <?php echo Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904733 Share on other sites More sharing options...
zoran Posted August 23, 2009 Author Share Posted August 23, 2009 They were set as default to those values. thanks a lot for help , this forum Rocks... Quote Link to comment https://forums.phpfreaks.com/topic/171556-php-5-and-mysql-changed-plase-help/#findComment-904741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.