Jump to content

taith

Members
  • Posts

    1,514
  • Joined

  • Last visited

Everything posted by taith

  1. secondly... [code] $adataselect[0]  = ""; . . . [/code] is much faster set once [code] $adataselect  = array('','','','',''); [/code]
  2. firstly... the more comments in the page, the larger the file, the larger the file, the longer it takes to load it (serverside).
  3. not with .php ... the webpage is stored in the temp files, along with all the images, changing it on the database/server wont change them on the computer without reloading/ajax.
  4. well... that depends... if the delete posts link is protected(admin or whatnot) $_GET[] is easier and faster... if they are open to anybody... use $_POST[] as you cant change the active sourcecode and much harder to hack...
  5. [code]$string='text text text text<br>'; echo ucfirst($string); echo ucwords($string);[/code]
  6. something to that effect maybe? [code] <?php if($handle = opendir('.')){ while (false !== ($file = readdir($handle))){   if($file != "." && $file != ".."){   $images[]=$file;   } } closedir($handle); } $current=$_GET[image]; if(empty($current)) $current=1; $prev=$images[$current-1]; $image='<img src="gallery/'.$images[current].'">'; $next=$images[$current+1]; ?> [/code]
  7. you can use that wherever you likes the only things that need to be prior to any output are things that are not sent along with the headers(cookies, session_start, print, etc)
  8. [code] $name = "test"; if(is_nan($name)) echo "GOOD"; else echo "BAD"; [/code]
  9. found something! http://us3.php.net/manual/en/function.printer-set-option.php [code] printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_A4); [/code] assuming your using a link to print the page, that might help, if your using file print, probly not...
  10. for example... [code]<?php $link = mysql_connect('host', 'username', 'password'); $db_selected = mysql_select_db('database', $link); $result = mysql_query("SELECT names FROM users WHERE `names`='bobby'"); while ($row = mysql_fetch_array($result)){ print "<p>$row[names]</p>"; } ?>[/code]
  11. [code] <?php include('header.inc'); $page = $_GET['url']; if(empty($page)) $page = 404_notfoud include($page.'.php'); include('footer'); ?>[/code]
  12. you had pc... should be site [code] <?php include("sql/conn.php"); mysql_select_db($db_name) or die( "Unable to select database"); $scrollresult=mysql_query("SELECT scroll FROM site"); $scroll=mysql_result($scrollresult,0,"scroll"); echo "currently set to $scroll<br/><br/>"; if($scroll=="yes") $newscroll="no"; else $newscroll="yes"; echo "now it's set to $newscroll<br/><br/>"; // here is where it dies $result=mysql_query("update site set `scroll`='$newscroll'") or die(mysql_error()); ?> [/code]
  13. heres one i just found... [url=http://www.analysespider.com/geo-targeting/geo-targeting.html]http://www.analysespider.com/geo-targeting/geo-targeting.html[/url]
  14. [code]$files = glob('*'); foreach($files as $file){ if(strpos(".",$file,1)==false) echo $file; }[/code]
  15. sorry... that wasnt tested... this should work... [code] <? error_reporting(E_ALL ^ E_NOTICE); mysql_connect("localhost","nancy","blabla"); mysql_select_db("nancy"); if(!isset($_GET["cmd"])){ $result = mysql_query("select * from news order by id"); while($r=mysql_fetch_array($result)){   echo '<p>endre nyheter:</p><a href="edit.php?cmd=edit&id='.$r[title].'">'.$r[id].'</a><br/>'; } }else{ if(!isset($_POST["submit"])){   $result = mysql_query("SELECT * FROM news WHERE `id`='$_GET[id]'");   $myrow = mysql_fetch_array($result); ?> <form action="edit.php?cmd=edit" method="post"> <table>   <tr>   <td>tittel:</td>   <td><input type="text" name="title" value="<?php echo $myrow["title"] ?>" size='40'></td>   </tr>   <tr>   <td>forfatter:</td>   <td><input type="text" name="author" value="<?php echo $myrow["author"] ?>" size='40'></td>   </tr>   <tr>   <td>tekst:</td>   <td><textarea name="news" cols='30' rows='5'><? echo $myrow["news"] ?></textarea></td>   </tr>   <tr>   <td></td>   <td><input type="submit" name="submit" value="endre"></td>   </tr> </table>  </form> <? }elseif($_POST["submit"]){   $result = mysql_query("UPDATE news SET title='$_POST[title]', `news`='$_POST[news]', `author`='$_POST[author]' WHERE id=$id");   echo "query finished."; } } ?> [/code]
  16. try that [code] <? error_reporting(E_ALL ^ E_NOTICE); mysql_connect("localhost","nancy","blabla"); mysql_select_db("nancy"); if(!isset($_GET["cmd"])){ $result = mysql_query("select * from news order by id"); while($r=mysql_fetch_array($result)){   echo "<p>endre nyheter:</p>";   echo "<a href='edit.php?cmd=edit&id=$r["title"]'>$r["id"]</a><br/>"; } }else{ if(!isset($_POST["submit"])){   $result = mysql_query("SELECT * FROM news WHERE id=$_GET['id']");   $myrow = mysql_fetch_array($result); ?> <form action="edit.php?cmd=edit" method="post"> <table>   <tr>   <td>tittel:</td>   <td><input type="text" name="title" value="<?php echo $myrow["title"] ?>" size='40'></td>   </tr>   <tr>   <td>forfatter:</td>   <td><input type="text" name="author" value="<?php echo $myrow["author"] ?>" size='40'></td>   </tr>   <tr>   <td>tekst:</td>   <td><textarea name="news" cols='30' rows='5'><? echo $myrow["news"] ?></textarea></td>   </tr>   <tr>   <td></td>   <td><input type="submit" name="submit" value="endre"></td>   </tr> </table>  </form> <? }elseif($_POST["submit"]){   $result = mysql_query("UPDATE news SET title='$_POST["title"]', `news`='$_POST["news"]', `author`='$_POST["author"]' WHERE id=$id");   echo "query finished."; } } ?> [/code]
  17. also, your missing the time field [code] $result=mysql_error("INSERT INTO news (title,message,who,date,time) VALUES ('$title', '$message', '$who', '$date')"); [/code]
  18. just as a forenote... you might want to remove the user/password from submitted code ;-)
  19. glob() is SOO much faster [code] $files=glob('images/*'); echo '<select>'; foreach($files as file) echo '<option>'.$file.'</option>'; echo '</select>'; [/code] you dont need an absolute path either
  20. no... php doesnt do that... it has access only to the headers... not the browser specifics that javascript can...
  21. that'll give you a string of random letters to any length you want [code] function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($i=0;$i<$length;$i++) $key .= $pattern{rand(0,62)}; return $key; } $x=randomkeys(1); echo $x; [/code]
  22. exactly, when i use distinct with path alone, it gives me one record... when i use it with id, it gives me all of them.
  23. when i take the id out, it works perfectly, but i need both of those columns, i need distinct path, and all id's associated with it. [code] $result=mysql_query("SELECT DISTINCT path, id FROM im_files WHERE (`uid1`='$id' AND `uid2`='$key') OR (`uid2`='$id' AND `uid1`='$key') ORDER BY id") or die(mysql_error()); [/code]
×
×
  • 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.