Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
1) Make sure to validate your HTML: http://validator.w3.org/check?uri=http%3A%2F%2Fvalentin.phpnet.us%2Fgame%2Fgame.php 2) Remove the animated images (they are ugly) 3) Get a design. It's just text with color. 4) Don't use non-breaking spaces to center things.
-
Could you quickly sum up? Which one was the fastest?
-
[quote author=tistaharahap link=topic=108431.msg436253#msg436253 date=1158533742] And for the question u asked, should use quotes with strings. [/quote] Yes. [i]Always[/i] put quotes around strings! The only place where they are optional are with integers and floats. If you have a boolean then it shouldn't.
-
Is the problem that the output looks wierd when you run the query from the CLI?
-
preventing new window pop up after e-mail form submission to php
Daniel0 replied to TrAsH's topic in PHP Coding Help
It's probably the actionscript doing it, but I can't help you with that since I don't know actionscript. -
I bet whatever you do I would be able to download the image. The only thing you can do, is to make it more difficult and hope that people will give up.
-
What's the most tables you have joined?
Daniel0 replied to extrovertive's topic in Application Design
[quote author=448191 link=topic=107987.msg434026#msg434026 date=1158223441] Only five or so. [u]Full[/u] normalization doesn't become that usefull untill you have tables that can potentially get huge, creating a huge amount of repeated data. So on a database that isn't likely to become that big, out of pure lazyness :P, I use it with moderation. [/quote] Moderation? Like in a forum system? I have a cache table containing things like group information, moderators, settings etc. so I can read from a lot of tables with only one query. The cached information is updated each time it's edited by an admin or so. -
This will get the server load. [code]<?php $loadavg_file = @file_get_contents('/proc/loadavg'); $loadavg_file = explode(' ',$loadavg_file); $loadavg = trim($loadavg_file[0]); if(empty($loadavg)) { $uptime_exec= explode(' ',@exec('uptime')); if(!empty($uptime_exec)) { $loadavg= $uptime_exec[count($uptime_exec)-1]; } else { $loadavg= '--'; } } echo "Server load: {$loadavg}"; ?>[/code]
-
I haven't tested it, but it should work: [code]<?php function replace_var($directory='.',$old_var_name='',$new_var_name='') { if(substr($directory,-1) != '/') { $directory .= "/"; } if($dh = @opendir($directory)) { while($item = @readdir($dh) != false) { if($item != '.' && $item != '..') { if(is_dir($directory.$item)) { replace_var($directory.$item); } else { $file_contents = @file_get_contents($directory.$item); $file_contents = str_replace('$'.$old_var_name,'$'.$new_var_name,$file_contents); $fp = fopen($directory.$item,'w'); fwrite($fp,$file_contents); fclose($fp); } } } } @closedir($dh); } replace_var("/var/www/some_script","old_var","new_var"); ?>[/code] [b]Edit:[/b] Note that it works recursively. If you wan't to remove that feature, just comment out [code]replace_var($directory.$item);[/code] (inside the function).
-
Does die automatically terminate mySQL connections?
Daniel0 replied to manmanman's topic in PHP Coding Help
1) I'm pretty sure all database connections terminate on the end of script execution. I believe mysql_close() is for if you want to close the connection before the script ends. 2) You could run a query every time somebody enters your site that will look like this: [code]$time = time()-(3600*24*48); @mysql_query("DELETE FROM users WHERE activated=0 AND registration_date<{$time}");[/code] -
Something like this should do it: [code]<?php include 'functions.php'; // contains functions to check if the user is logged in include 'db.php'; // connects to the database if(is_logged_in()) { $id = intval($id); $query = mysql_query("SELECT * FROM downloads WHERE id='{$id}' LIMIT 1"); if(mysql_num_rows($query) <= 0) { echo "Sorry, no such file."; } else { $file_info = mysql_fetch_assoc($query); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($file_info['path'])); header("Accept-Ranges: bytes"); header("Content-Length: ".filesize($file_info['path'])); header("Content-Description: File Transfer"); @readfile($file_info['path']); die(); } } else { echo "Sorry, you need to be logged in to download this file."; } ?>[/code]
-
system("ifconfig"); exec("ifconfig"); Try check the manual first: http://www.php.net/manual/en/index.php
-
Did you put a hidden MAX_FILE_SIZE field in your form?
-
[code]<?php $num = 0; while(1==1) { sleep(10); $num++; } ?>[/code] Will increase by 1 every ten seconds.
-
Is this possible within PHP? If not - what technology do I need?
Daniel0 replied to Anidazen's topic in PHP Coding Help
You can't do more than one thing at a time, that goes for all the other languages as well. -
I don't think that would work This will work: test.php [code] <?php session_start(); $_SESSION['name'] = "something"; echo"<a href='test_result.php'>please see my name</a>"; ?> [/code] test_result.php [code] <?php session_start(); echo "Hello there my name is {$_SESSION['name']}"; ?> [/code]
-
In order to ratin variables across pages you could use sessions. Put [code]session_start()[/code] before anything is output (eg on the top of the page) and define the variables like $_SESSION['something']. You would then be able to call it on another page (which has ran session_start() too) as $_SESSION['something'].
-
Something like this should do it: [code]<?php $conn = mysql_connect("localhost", "username", "password"); mysql_select_db("some_database", $conn); $q = mysql_query("SELECT * FROM users"); if(mysql_num_rows($q) <= 0) { echo "No users"; } else { echo <<<EOF <table> <tr> <th>Username:</th> <th>Email:</th> <th>Website:</th> <th> </th> </tr> EOF; while($u = mysql_fetch_assoc($q)) { echo <<<EOF <tr> <td>{$u['username']}</td> <td><a href="mailto:{$u['email']}">{$u['email']}</a></td> <td><a href="{$u['website']}">{$u['website']}</a></td> <td><button type="button" onclick="location.href='http://www.example.com/change.php?var={$u['username']}'">Some button</button></td> </tr> EOF; } echo "</table>\n"; } ?> [/code]
-
Yeah. Just note that EOF; has to be on a line for it self. There may not be any whitespaces on the line EOF; is on (that also means no idendtion).
-
[Solved]Problem with click count script
Daniel0 replied to wwfc_barmy_army's topic in PHP Coding Help
[code]Change [code]$sql="UPDATE site SET clicks=clicks+1 WHERE (id = '$id')";[/code] to $sql="UPDATE site SET clicks=clicks+1 WHERE (id = '{$_GET['id']}')";[/code] -
Try this for the function then: [code]<?php function aLogin($user, $pass) { $dbname = ""; $dbuser = ""; $dbpass = ""; $dbhost = ""; $connection = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error Connecting: ".mysql_error()); @mysql_select_db($dbname, $connection) or die("Error Selecting Database:".mysql_error()); $result = @mysql_query("SELECT * FROM admin_user WHERE name='{$user}' LIMIT 1") or die ("Error Retrieving Data: ".mysql_error()); if(mysql_num_rows($result) <= 0) { echo "The user '{$user}' do not exist!"; } else { $udata = mysql_fetch_assoc($result); if($udata['name'] != $user || $udata['pass'] != $pass) { echo "Invalid username or password! Press back and try again!"; } else { $_SESSION['usern'] = $udata['usern']; $_SESSION['ulvl'] = $udata['ulvl']; header("Location: main.php" ); die(); } } } ?> [/code]
-
Try this. Note that I made your code look more nice. Login function: [code]<?php function aLogin($user, $pass) { $dbname = ""; $dbuser = ""; $dbpass = ""; $dbhost = ""; $connection = @mysql_connect($dbhost, $dbuser, $dbpass) or die("Error Connecting: ".mysql_error()); @mysql_select_db($dbname, $connection) or die("Error Selecting Database:".mysql_error()); $result = @mysql_query("SELECT * FROM admin_user WHERE name='{$user}'") or die ("Error Retrieving Data: ".mysql_error()); while($data = mysql_fetch_assoc($result)) { $ulvl = $data['ulvl']; $usern = $data['name']; $pass1 = $data['pass']; } if(!$usern) { echo "Invalid username or password! Press back and try again!"; } else { if($pass == $pass1) { $_SESSION['usern'] = $usern; $_SESSION['ulvl'] = $ulvl; header("Location: main.php"); //we will redirect the user to another page where we will make sure they're logged in } else { echo "Invalid Password!"; } } } ?>[/code] index.php: [code]<?php session_start(); include("../db.php"); include("../functions.php"); echo '<link rel="stylesheet" href="../style/id1.css" />'; if(!$_GET['id']) { echo <<<EOF <div align="center"> <p>RSLegion Admin Login Page</p> <p><a href="../">Back to Website</a></p> <p> </p> <form name="form1" method="post" action="index.php?id=1"> <p>Username: <input name="user" type="text" id="user" size="20" maxlength="20" /></p> <p>Password: <input name="pass" type="password" id="pass" size="20" maxlength="20"></p> <p><input type="submit" name="Submit" value="Log In"></p> </form> <p> </p> </div> EOF; } else { aLogin($_POST['user'], $_POST['pass']); } ?>[/code]
-
[Solved]Problem with click count script
Daniel0 replied to wwfc_barmy_army's topic in PHP Coding Help
The solution to your problem is output control. By using ob_start() all the output you send will be stored in a buffer, that means it don't actually get output yet. Then you can output something and run the header function, since it weren't really output. ob_end_flush() outputs what was buffered, ends the output buffering and clears the output buffer. [code]<?php ob_start(); include("dbconnect.php"); // clickcount is the table, with 2 columns: id and clicks $sql="UPDATE site SET clicks=clicks+1 WHERE (id = '$id')"; $result=mysql_query($sql,$dbcnx); $url = $_GET['url']; header("Location: http://$url"); /* Redirect browser to web site */ exit; // just to be nice ob_end_flush(); ?>[/code] -
You did not search very well then :P [url=http://www.google.com/search?q=mov+converter+mpeg]Google search on "mov converter mpeg"[/url] gives a lot of results. Even [url=http://www.google.com/search?q=how+can+i+convert+mov+files+to+mpeg+files%3F]searching on "hov can i convert mov files to mpeg files?" (without quotes)[/url] gets the same site on the top.