How can i add a php script with DB connection?

oly1993

Member
I want to add this code for the vote pagina / gatewaypage,
but i get the error "header already send...." and i was trying to put it in index.php, and get a DB connection error.

Can someone make it working?
Script :
Code:
<?php

 
    //-- ip opslaan in een variable
    $ip = $_SERVER['REMOTE_ADDR'];

    //-- haal het specifieke ip adres uit de database 
    $sql = "SELECT * FROM proxy WHERE ip = '".$ip."'";
    //-- via de functie mysql_query() kun je de SQL code
    //-- die in $sql staat uitvoeren.
    $res = mysql_query($sql);
    //-- via de functie mysql_fetch_array() zet je 
    //-- alle velden die je zojusit geselecteerd hebt 
    //-- van het specifieke ip adres in een array.
    //-- je kunt ze dus aanroepen via $row[kolom_naam].
    $row = mysql_fetch_array($res);


if(mysql_num_rows($res) == 0) {
//*als er geen proxy is gevonden, is de website zichtbaar

}else{
//* proxy gevonden

echo '
<div class="layer">
<div class="content">
<h2>Proxy gevonden</h2>
<hr>
Er is proxy gevonden. Probeer het nogmaals, maar dan zonder proxy.
<hr/>
<center>&copy;2013 Marco Eilander - Alle rechten voorbehouden.</center>
</div>
</div>
';
exit();
}

?>
 

oly1993

Member
@Mark : Parse error: syntax error, unexpected '}' in /home/roelkil98/domains/maffia-toplijst.nl/public_html/index.php on line 2

or is this special for HTML files like gateway?

Added :
Warning
: file_get_contents(http://www.maffia-toplijst.nl/proxy-detection.php) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/roelkil98/domains/maffia-toplijst.nl/public_html/sources/misc/skin.php(175) : runtime-created function on line 1

Error when im using it in gateway.htm(l)
 
Last edited:

Mark

Administrator
Staff member
That error says the file does not exist. That can only mean 1 thing.

This your web server spitting out this error, not visiolist.


Perhaps you have missed the quotes around the URL, or perhaps you have space somewhere, or perhaps this function (URL file include) is disabled in your web host. You will need to look closer.
 

oly1993

Member
I've no idea, what the problem is.

1) There're no errors on : http://www.maffia-toplijst.nl/proxy-detection.php
2) I put {include "http://www.maffia-toplijst.nl/proxy-detection.php"} in gateway.html

Code:
<body>
{include "http://www.maffia-toplijst.nl/proxy-detection.php"}
<div id="gatewrap"><div id="gatewrap2">
    <h1>{$lng->gateway_header}</h1>

        <div id="gateway-top">{$gateway_top}</div>

        <p class="gatemessage">{$lng->gateway_text}</p><br /><br />
        <a href="{$list_url}/" class="visio_button large_button red" target=""><span>{$lng->gateway_no_vote}</span></a>
        <a href="#" class="visio_button large_button green" id="vote" target=""><span>{$lng->gateway_vote}</span></a>
       
        <p>
        {$url} - {$description}
        </p>
       
        <div id="gateway-bottom">{$gateway_bottom}</div>

</div></div>
</body>
</html>
3) and the result : Warning: file_get_contents(http://www.maffia-toplijst.nl/proxy-detection.php) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/roelkil98/domains/maffia-toplijst.nl/public_html/sources/misc/skin.php(175) : runtime-created function on line 1

- Gateway.html = skins/parabola/
- proxy-detection.php = public_html/
 

Mark

Administrator
Staff member
your code is fine, I tested on our demo list and it works as expected.

Since your web server is returning a 404 error it means it cannot open the file, most likely you need to enable "allow_url_fopen" in php.ini or ask your web host.
 

oly1993

Member
your code is fine, I tested on our demo list and it works as expected.

Since your web server is returning a 404 error it means it cannot open the file, most likely you need to enable "allow_url_fopen" in php.ini or ask your web host.

Message from the webhost :

Geachte heer/mevrouw,

Het is niet mogelijk om deze PHP functie te gebruiken. Deze is bij ons uitgeschakeld en zal niet geactiveerd worden. Mocht u verder nog vragen hebben dan helpen wij u uiteraard graag verder.

Alex Boon
Level 1 Helpdesk Medewerker: support@versio.nl
http://www.versio.nl/
A bit translated :
It's not possible to use this php function. The function is off and will not be activated.
 
Top