Code Blog
We know what is the code

Home Page




Posts Tagged ‘Php Code’

What ’s wrong with my php code?

I am trying to insist to php, to break after it has writen an ip address and date, but it will actually write “
,” and “/n” how can i actually make it break with a new line.
=========================…
function ipset(){
$ip = $_SERVER["REMOTE_ADDR"];
$new_file = "addresses.txt";
$file_handle = fopen($new_file,'a');
fwrite($file_handle,
$ip."-".date("m/d/Y").
"
“)/n;
fclose($file_handle);
ipset();
}
?>
=========================…

OUTPUT in textfile:
(making more than one line because text box won’t let me put long strings…)
=========================…
69.152.147.191-06/06/2007
(continue string on next line*)

69.152.147.191-06/06/…
(continue string on next line*)

=========================…

By: truepal20032001



3 Comments

PHP Code Question?

Can somebody change the code below so that it covers the entire range of IP’s for 97.200.11 (instead of just the one IP). I’ve attempted to insert wildcards (*), remove the ” marks and everything else I’ve thought of. Thanks.

$host = getenv("REMOTE_ADDR");

if ($host == "63.97.200.11") { $redirect = "Location: http://www.google.com"; }

header ($redirect)
?>
Okay it works now. Thank you all for the great answers.

By: webmaster



3 Comments

Please help me? Where from collect India News Ticker (HTML Code)?

Please give News ticker for india news (HTML Code/ PHP Code or any other source code) for my site

By: Ram



No Comments

What’s the answer to this php riddle?

A guy codes this PHP code. Set getvar to execute /etc/bin/wtf.
$getit = “hts”.’f'; $y = $_GET['getvar']; eval(”\$getit = \$y;”);

By: Des Racoga



1 Comment

Problem with PHP and cookies! Open for more details:?

im new and im trying to… when someone enter there username in index.php and press on submit the page to load user.php and desplay this user name with the help of cookies, but this is what i get (some text is in bulgarian):

Hello, $username!
Click here to change your username or click here to continued!

the index.php code is:

Please enter your username:

the user.php code is:
setcookie ("user", $username);
?>
echo 'Hello, $username!
Click here, to change your username or click here to continued!’
?>

ps: im useing WAMP5 1.6.6

By: Mitko



No Comments

Can anyone help figure out wats wrong.its a database driven site?



Alarm Codes









Alarm Code:
Alarm Description:

//This is only displayed if they have submitted the form

if ($_POST['searching'] =="True")
{
echo "

Results

“;

//If they did not enter an alarm we give them an error
if ($find == “”)
{
exit;
echo “

You forgot to enter an alarm code”;
}

// Otherwise we connect to our Database
mysql_connect(”localhost”, “eoin”, “password”) or die(mysql_error());
mysql_select_db(”alarm_codes”) or die(mysql_error());

// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);

//Now we search for our search term, in the field the user specified
$data = mysql_query(”SELECT * FROM users WHERE upper($field) LIKE’%$find%’”);

//And we display the results
while($result = mysql_fetch_array( $data ))
{
echo $result['codes'];
echo ” “;
echo $result['description'];
echo “
“;
echo “
“;
}

//This counts the number or results - and if there wasnt any it gives them a little message explaining that

$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo “Sorry, but we can not find an entry to match your query. Please add this alarm

“;
}

//And we remind them what they searched for
echo “Searched For: ” .$find;
}
?>




The search bar come’s up fine but the php code is also coming up. i have my apache server running. I think it might have something to do with

3 Comments

i need a php code that will make a direct link to download a file?

for example. http://xxx.com/phpcode.php?dl=link2afile
phpcode.php is the code and link2afile is the link to download the file.
This will return the direct link to download the file.

thank you for help!

By: ian a



2 Comments

PHP with SMTP auth? Please help PHP Coders?

Okay, i need help with writing a PHP code, im somewhat new to PHP so here what i want…Basically i would like you to write a basic PHP code for me. Heres what i want.

-mail() function
the mail function must include $to, $nameto, $from, $namefrom, $subject, and $message.

-Also, i need it to connect to an SMTP server WITH authentification, the server name is mail.bluebottle.com.

Thanks, if you could basically just give a code that would be great! no links please!

Thanks again,

EZ

By: Dale



3 Comments

php script. how to parse a url?

well i want to do somet like you see in google search

for e.g: http://mysite.com/my.php?code=12

now i cant the php script to redirect my site to somet thats given the name 12

like if games.php is assigned to the code 12

then when i pass 12 to the php script he should load games.php

_______________________________

question 2…?

how can i show the number 12 in a text box…..out of the url

http://mysite.com/my.php?code=12

i mean how can i parse the url and get the value out of the url

like code=12

now i want to parse the full url and just get the value of code=
what ever code is equal to he should display it in a text box….

By: sharpturds



2 Comments

View local.PHP files in IE & Firefox?

I’m trying to view a local (on my HDD) .php file in IE7 or FireFox - but IE7 is asking to save or download the file, and Firefox just interprets it as text - all I see is the code.

Note that it was working until I formatted my PC, so it’s a setting obviously… but I’ve forgotten how / where.

I don’t run a PHP server locally on my machine, but note these files mainly contain HTML code, and I just want to view them for design / preview reasons. I don’t care about not-seeing the PHP code until I upload it… but currently, I can’t even view the files locally.

Any thoughts? :) Thank you.
Hrm.. I’m a web designer and I know I didn’t have a web server running - but I’m sure I was able to view locally - the browser would just interpret the file as html - it’s all formatted like a normal HTML page - start and ends with all the right tags, just has one line of php in it.

I’m thinking it’s something like this, except I can’t get it to work… unless I need to reboot my machine - or are Registry edits immediate?

Ref.: http://www.webmasterworld.com/html/3096069.htm

By: andypudmenzky



6 Comments