Jump to content

lightningstrike

Members
  • Posts

    155
  • Joined

  • Last visited

    Never

Everything posted by lightningstrike

  1. I believe you need an additional } bracket at the end of your code provided.
  2. for ($i=1;$i<=15;$i++){ $x = "op" . $i; if ((!empty($_POST[$x]) && ($_POST[$x] != NULL)) { $opt[] = array($_POST[$x]); } } You were using invalid syntax.
  3. Textarea's create the code \n on it's own accord when a user hit's enter. \n is a newline character that the browser processes, in textarea's but not in actual html. So nl2br() is your best bet
  4. Perhaps you need to look into the nl2br() function before adding it to the database. alternatively something like this could be done. $text = str_replace("\n","</p><p>",$text); $text .= "</p>"; Your problem is the textarea considers hitting the enter key as a newline character or \n
  5. it makes sense, since your phpinfo file is probably using the .php extension not .php5
  6. If you want to remain using the .php extension for version 5.0 and ahve access to your .htaccess files. simply add in it. AddHandler application/x-httpd-php5 .php or AddType application/x-httpd-php5 .php depending on config.
  7. the script i provided you works fine on my setup, session_register has no benefits...
  8. perhaps this... $value = time() - (3600*24*7); mysql_query("DELETE FROM `bulletins` WHERE `date` < " . $value . "");
  9. session register is deprecated use the new standard of session superglobal. e.g. $_SESSION["username"] = "value"; and rather then session_unregister use unset e.g. unset($_SESSION["username"]); etc. also when comparing two variables in if ($username=="$uname") { you should not use quotes if ($username==$uname) { <?php require ("config.php"); session_start(); if ((!$_POST["username"]) || (!$_POST["password"])) { echo '<form name=login method=post action=""> user:<input type=text name=username><br> pass:<input type=password name=password><br> <input type=submit value=go> </form>'; }else{ if ($_POST["username"]==$uname && $_POST["password"]==$pword) { $_SESSION["username"] = $_POST["username"]; $_SESSION["password"] = $_POST["password"]; echo "user is $uname, and password is $pword <br> <a href=\"?m=1\" >unreg</a>"; } else echo "nope"; } if ($_GET["m"]==1) { unset($_SESSION["username"]); unset($_SESSION["password"]); } Do NOT use register_globals its dangerous for server security.
  10. lol no problem, just remember to press the topic solved button.
  11. You need to open the FILE "../test" and empty its contents.
  12. Ok I think i have the script properly re-written. Ill just add it at the end of this post. <html> <head><title>911 Dispatch Logs</title></head> <body bgcolor="#002233" text=white> <H1>911 Dispatch Logs - <a href=" hidden "><font color="#CCCCCC" size="2">Refresh</a></font> </H1> <?php // This is a form with "sticky" fields ..... ?> <form method=post> <TABLE BORDER="0" CELLPADDING="2" CELLSPACING="2" WIDTH="50%"> <TR> <TD>Department:</TD> <TD><select name=one> <?php $compass = array("Center Point","Birmingham","Trussville","Fultondale") ; $color = array(0=>"#BBBBBB",1=>"#CCCCCC",2=>"#FFFFFF",3=>"#EEEEEE"); $i = 0; foreach ($compass as $possibility) { echo "<option style=\"background-color: " . $color[$i] . "\""; if ($_POST["one"] == $possibility) echo "selected=\"selected\""; echo " value=\"" . $possibility . "^" . $color[$i] . "^\">" . $possibility . "</option>\n"; $i++; } ?></select></TD> </TR> <TR> <TD>Received:</TD> <TD><input name=two size=60 maxlength=100 value="<?php date_default_timezone_set('UTC'); echo date(DATE_RFC822);?>"<?php echo (htmlspecialchars(stripslashes($_POST["two"]))); ?>" size=15></TD> </TR> <TR> <TD>Unit(s):</TD> <TD><input name=three size=60 maxlength=100 value="<?php echo (htmlspecialchars(stripslashes($_POST["three"]))); ?>" size=15></TD> </TR> <TR> <TD>Location:</TD> <TD><input name=four size=60 maxlength=100 value="<?php echo (htmlspecialchars(stripslashes($_POST["four"]))); ?>" size=15></TD> </TR> <TR> <TD>Type of Call:</TD> <TD><input name=five size=60 maxlength=100 value="<?php echo (htmlspecialchars(stripslashes($_POST["five"]))); ?>" size=15></TD> </TR> <TR> <TD>Details:</TD> <TD><input name=six size=60 maxlength=100 value="<?php echo (htmlspecialchars(stripslashes($_POST["six"]))); ?>" size=15></TD> </TR> </TABLE> </select> <input type="Submit" value="Submit" name="Submit"> <input type="Reset" value="Clear" name="Clear"> </form> <?php // Save all the fields on any previous form to a file if(isset($_POST['Submit'])){ $fh = fopen("../test","a"); fputs($fh, $_POST["one"]." | ". $_POST["two"]." | ". $_POST["three"]." | ". $_POST["four"]." | ". $_POST["five"]." | ". $_POST["six"]."". "\n"); fclose($fh); } // Echo the file contents onto the end of the form $stuff = implode("",file("../test")); $value = explode("\n",$stuff); $count = count($value); for($i=0;$i<$count;$i++){ $b = explode("^",$value[$i]); $b[0] = stripslashes(htmlspecialchars($b[0])); $b[1] = stripslashes(htmlspecialchars($b[1])); $b[2] = stripslashes(htmlspecialchars($b[2])); print "<span style=\"color: " . $b[1] . "\">" . $b[0] . "</span>" . $b[2] ."<br>"; } ?> </body> </html> I was busy earlier but I managed to make up some sort of solution. All you have to do to change colours is view a hex chart like this http://www.draac.com/hexchart.html and modify the values in the $color array accordingly.
  13. rather use $color = array(0=>"#BBBBBB",1=>"#CCCCCC",2=>"#FFFFFF",3=>"#EEEEEE"); $i = 0; foreach ($compass as $possibility) { echo "<option style=\"background-color: " . $color[$i] . "\""; if ($_POST["one"] == $possibility) echo "selected=\"selected\""; echo "value=\"" . $possibility . ":" . $color[$i] . ":>" . $possibility . "</option>\n"; $i++; } and for the file printing replace echo (nl2br(htmlspecialchars(stripslashes($stuff)))); with $value = explode("\n",$stuff); $count = count($value); for($i=0;$i<$count;$i++){ $b = stripslashes(htmlspecialchars(explode(":",$value[$i]))); print "<span style=\"color: " . $b[1] . "\">" . $b[0] . "</span>" . $b[2]; } removed an extra "
  14. $color = array(0=>"#BBBBBB",1=>"#CCCCCC",2=>"#FFFFFF",3=>"#EEEEEE"); $i = 0; foreach ($compass as $possibility) { echo "<option style=\"background-color: " . $color[$i] . "\" value=\"<span style=\"color: " . $color[$i] . "\">" . $possibility . "</span>\""; if ($_POST["one"] == $possibility) echo "selected=\"selected\""; echo ">" . $possibility . "</option>\n"; $i++; } something like that, so when you load the file they'll be colored, provided you remove the <FONT style="BACKGROUND-COLOR: #808080">
  15. Umm the link you gave me is a restricted area so I have no idea what to see.
  16. remove stixy SELECT COUNT( * ) AS `Rows` FROM `emailists` or GROUP BY stixy SELECT COUNT( * ) AS `Rows` , `stixy` FROM `emailists` GROUP BY `stixy` or perhaps separate them into two separate queries.
  17. I think he forgot the ? mark foreach ($compass as $possibility) { $sel = ($_POST['val'] == $possibility) ? 'selected="selected"' : ''; echo "<option value=\"". $possibility ."\" ". $sel .">". $possibility ."</option>\n"; }
  18. SELECT COUNT( * ) AS `Rows` , `stixy` FROM `emailists` I believe that query is incorrect as mixing of columns and special operators such as COUNT, SUM is not allowed without a GROUP BY clause.
  19. $color = array(0=>"#BBBBBB",1=>"#CCCCCC",2=>"#FFFFFF",3=>"#EEEEEE"); $i = 0; foreach ($compass as $possibility) { echo "<option style=\"background-color: " . $color[$i] . "\""; if ($_POST["one"] == $possibility) echo "selected=\"selected\""; echo ">" . $possibility . "</option>\n"; $i++; } maybe something like that
  20. umm that was sloppy coding on my part foreach ($compass as $possibility) { echo "<option style=\"background-color: " . $color[$i] . "\""; if ($_POST["one"] == $possibility) echo (" selected"); echo ">$possibility"; } but you will have to make some modifications to your needs.
  21. just create an array with the colours in it for each value...then echo back echo "<span style=\"" $color[$i]\">$compass[$i]</span"; or something similiar
  22. Does your webhost give you access to phpMyAdmin through cpanel,whm,vdeck,plesk,ensim etc? If so then you can easily view the contents of the database through phpMyAdmin's visual interface.
  23. You could use a crontab to execute a script to remove all users who in the active table haven't loaded a new page for x minutes. Having the crontab run every x minutes. Or simply have a script which runs 1/3 page views or so that performs a query like $wait = 600; //seconds to delete $value = time() - $wait; DELETE FROM user_active WHERE lastvisit<$value;
  24. $query = "SELECT DISTINCT t1.year,t2.year,count(*) FROM test1 AS t1,test2 AS t2 GROUP BY t1.year,t2.year"; $res = mysql_query($query); while($row = mysql_fetch_array($res)){ print_r($res); } prehaps try debugging with this by viewing the results of the query.
  25. Try joining the queries perhaps. SELECT DISTINCT t1.year,t2.year,count(*) FROM test1 AS t1,test2 AS t2 GROUP BY t1.year,t2.year
×
×
  • 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.