Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. for a default page you can update the code //Get Page selected $page = (empty($_GET['str']))?0:$_GET['str']; to //Get Page selected $page = (empty($_GET['str']))?"page_1":$_GET['str']; that will make page_1 the default page. can you post the PageLinks function and I'll take a look
  2. you need to read the file from the remote source (you need allow_url_fopen on), then write the file to a local file, if its small you could use file_get_contents file_put_contents for larger files fopen would be better.
  3. First of all what your doing won't work, you need to use GET instead of POST, also i improved the session killer, to clear the session, remove the PHPSESSID cookie and then destroy from the server. <?php //switch($_POST['action']){ switch($_GET['action']){ case 'logout' : session_start(); session_start(); $_SESSION = array(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000,$params["path"], $params["domain"],$params["secure"], $params["httponly"]); } session_destroy(); header("location:index.php"); break; default: echo "unknow action!\n"; } ?> This means your permissions are set incorrectly, change then to 755, This could be a few things but its normally when a file is used at the wrong type.. it could be related to the header, but would need more details (action's that cause it)
  4. If you can post a HTML example of the selected page and unselected pages i could update it for you. basically your need to change if($page == $k){ $str .="<p><strong><a href=\"index.php?str=$k\">$v</a></strong></p>\n"; }else{ $str .="<p><a href=\"index.php?str=$k\">$v</a></p>\n"; } to something like this if($page == $k){ $str .="<p class=\"selected\"><strong><a href=\"index.php?str=$k\">$v</a></strong></p>\n"; }else{ $str .="<p class=\"unselected\"><a href=\"index.php?str=$k\">$v</a></p>\n"; }
  5. MadTechie

    Iframe

    I added a list of free AntiVirus, to the Which Antivirus program are you using? Thread, that may be helpful in this case. also Panda Cloud maybe an option! (untested but is very light weight so it doesn't use up all your system resources, and its free)
  6. I guess you could do something like this <?php //Full page list $pages = array( "page_1"=>"Main Page", "page_2"=>"Page2", "page_3"=>"Page3", "page_4"=>"Page4", ); //Get Page selected $page = (empty($_GET['str']))?0:$_GET['str']; //Display links echo PageLinks($page,$pages); //check selected page is correct name format if(preg_match('/^[\-_a-z0-9]+$/i', $page)){ $file = "$page.html"; //check page exists if(file_exists($file)){ include($file); exit; } } //any faults display home page include "index.html"; function PageLinks($page, $pages){ $str = ""; foreach($pages as $k => $v){ if($page == $k){ $str .="<p><strong><a href=\"index.php?str=$k\">$v</a></strong></p>\n"; }else{ $str .="<p><a href=\"index.php?str=$k\">$v</a></p>\n"; } } return $str; } ?>
  7. Is the ID current used in other database records ? if it is then an update could be a pain, but i would probably create a function to run once to clean up the data, rather than a function to attempt to get around it, as it could cause problems later will affect performance from the start
  8. MadTechie

    Iframe

    I just loaded the link in your iframe, and my AV denied me access, for anyone who doesn't have an AV here's the warning!
  9. SQL command ALTER TABLE `games` AUTO_INCREMENT =9737 or ALTER TABLE `games` AUTO_INCREMENT =MAX(ID) + 1
  10. MadTechie

    Iframe

    LOL, I have done the same.. I was updating a local copy and viewing a remote copy.. it didn't take me too long to , but longer than i care to admit. However the reason i say Virus.. be because they often use iframes (often at the end of the file) and i assume he's working only locally and opening the file saving it and then reopening if and it back. however its a valid point!
  11. 2147483647 is the highest AUTO_INCREMENT, you can have, so I'll assume you have 2147483647 records! either that or sort by ID and find the highest and set the AUTO_INCREMENT to that!
  12. MadTechie

    Iframe

    Virus ! could be Virus.Win32.Virut.bo scan your PC for virus,
  13. if(!(strlen($user) >= 3 && strlen($user) <= 15)){ echo 'Username must be atleast 3 characters, and no longer than 15!'; } //Slower RegEx if(!preg_match("/^\w{3,15}$/", $user)){ echo 'Username must be atleast 3 characters, and no longer than 15!'; }
  14. Erm...I'm not sure where to start! // assign values of $tp[] to array() below $SQLQuery = array($tp[0],$tp[1],$tp[2],$tp[3],$tp[4],$tp[5],$tp[6],$tp[7],$tp[8],$tp[9],$tp[10]); // $SQLQuery = array(1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0); <- output something like this Okay $tp is an array of one's and zeros and you seam you want to transform it into .. itself!.. Note: to see an arrays output, use can use print_r print_r($tp); Note#2: for nice formatting add echo "<pre>"; before the print_r as for question #2.. after reading the question 3 times i assume you mean this. whats the most amount of consecutive occurrences of 1, ie $SQLQuery = array(1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0); would be 6, script <?php $tp = array(1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,0); echo countMaxOcc($tp,1); function countMaxOcc($tp, $s){ $t=0;$c=0;$p=true; foreach($tp as $n){ if($n==$s){ $c=($p)?$c+1:1; $p=true; }else{ $t=($c>$t)?$c:$t; $p=false; } } return $t; }
  15. As Daniel has already stated: Your script is reading data from PHP's own internal buffer, (You shouldn't use this value in a script.) if it works then your going to have problems with at least reliability, I guess you could add this above the line if(empty($status["unread_bytes"])) trigger_error("Failed to get any data",E_USER_ERROR); If the script works on one port but not another and looking at the error i would guess that it not getting any data from that server on that port!!
  16. As your using MySQLi, You could just adjusts the result pointer to row 0 of $result (mysqli-result.data-seek) e.g. $result->data_seek(0); also check mysqli.store-result
  17. You could but personally i dislike DM when it comes to writing PHP code, I assume your database has a primary field (I'll assume its ID) and i have taking parts of your code, to create a sample script to allow editing, assuming the script was called edit.php and you had a field ID of 10, you could edit it via edit.php?ID=10 Heres the sample <?php require_once('Connections/webform.php'); ?> <?php $ID = $_GET['ID']; mysql_select_db($database_webform, $webform); //Save Data if(isset($_POST['submit'])){ $query_update = sprintf("UPDATE contactForm SET (`name`,`email`) VALUES ('%s','%s') WHERE ID = %d", mysql_real_escape_string($_POST['name']), mysql_real_escape_string($_POST['email']), $ID); mysql_query($query_update, $webform) or die(mysql_error()); } //Get Data $query_select = sprintf("SELECT * FROM contactForm WHERE ID = %d",$ID); $select = mysql_query($query_select, $webform) or die(mysql_error()); $row_select = mysql_fetch_assoc($select); ?> <div id="form"> <form id="form1" name="form1" method="POST" action="?ID=<?php echo $ID; ?>"> <fieldset> <legend>Contact Details</legend> <ol> <li> <label for="name">Name: <em>required</em></label> <input id="Name" name="name" class="text" type="text" value="<?php echo $row_select['name'];?>"/> </li> <li> <label for="email">Email Address: <em>required</em></label> <input id="Email" name="email" class="text" type="text" value="<?php echo $row_select['email'];?>"/> </li> <fieldset class="submit"> <input class="submit" type="submit" value="Update"/> </fieldset> </form> </div> Please not i have had to take a few guesses and this is untested but should help you on your way. [ot]Oh and the reason I dislike DM is because it seams to give to less control and is very generic, a guy I work with only knew PHP via DM and after a I gave him little training he hates the DM generated code and now he only use DM for page design, if you understand all the code it creates then fine but most do not and those who do rarely allow DM to create their code, but these are my own opinions. [/ot]
  18. Add function function addnbspace($str, $len){ if (strlen($str) >= $len){return $str;} return $str . str_repeat(" ", $len-strlen($str)); } and replace your addspace with addnbspace, BUT it maybe an idea to use a table instead
  19. The PHP code will have to be at the bottom, for it to work I have no idea as that string is concatenated and without seeing the start of it or the results i can't say
  20. The form action should be set to the URI of the script that will process the forms data, So lets say you have a form.html file that contains the form and a form.php that contains the php script for that form, you would need to set the action of (in form.html) to form.php. this will send all the post requests from form.html to form.php.
  21. Or you could use <BR /> and on a HTML email
  22. okay this would be over the top, but if it doesn't work then we're need to re-think the approach, /*CleanText will remove any character that is not a to z or 0 to 9 Eg, $supName=CleanText($supName);*/ function CleanText($str){ return preg_replace('/[^a-z0-9]/i', '', $str); } however i personally would analyze the string, for example echo debugText("testing"); function debugText($str){ $array = str_split($str,1); $debug = ""; foreach($array as $arr){ // & # (without the space) seams to display incorrectly in the code box! $debug .= '&'.'#'.ord($arr).";"; } return $debug; } this will display BUT if you view source your see now check to see if their is any extra characters for example If i enter then i would get
  23. That value is empty until you post, then it will be set, but your need to post it again, so it makes sense to grab it from the database instead
  24. Opps I did it again! Ignore my first post.. I completely missed the question! (got it around the wrong way) however.. another quick dirty option is <?php file_put_contents("stylesheet-public.css",file_read_contents("http://yourDomain.com/yourCSS.php")); Now you must read from the HTTP address, this will read the file from apache instead of direct, this will then parse the file for you, as if you was a client But as Zanus said.. why ?
×
×
  • 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.