Jump to content

Hooker

Members
  • Posts

    193
  • Joined

  • Last visited

    Never

Everything posted by Hooker

  1. thats exactly what i was looking to find out, it's been a long night and i just could'nt get my head around a simple way to do it, thanks!
  2. in a mysql table, basicaly the table will be set out like so (sorry i didn't include this sooner ): UID | X_axis | Y_axis | Owner UID = unique ID X_axis = the x axis on the grid Y_axis = the y axis on the grid Owner = the owners UID then the info held on the coordinates will be held in a different table and so will the info on the owner
  3. I'm trying to write a little script to calculate distances in a grid.. basicaly i have a grid 10,000 by 10,000 large. In that grid quite randomly i have data on certain coordinates (i.e 395 | 900 etc), each coordinate on the grid has its own page, people take over their own part of the grid (basicaly there own place on a map) and fill information in on their grid, what i would like to do is calculate what other coordinates within 10 grid points in all directions are currently "inhabited", like that grid referrances neighbours. I hope that makes sense, its kind of confusing for me to explain but if you need any more info just ask. *edit* Hopefully this will help:
  4. There are a few AJAX shoutboxes floating about, that should do the job.
  5. Try this, it should let you round up or down depending on what you want <?php function rounding($no,$direction) { $skip=0; if(is_float($no) and $direction = 1) { $exploded = explode(".",$no); $nrr = $exploded[0]+1; $skip=1; } if(is_float($no) and $direction = 0) { $exploded = explode(".",$no); $nrr = $exploded[0]; $skip=1; } if(!is_float($no) and $skip ==1) { $nrr = $nrr; } else { $nrr = floor($nrr); } return $nrr; } ?> Use it like this: echo rounding(1.6,0); Enter the number first followed bya boolen, 1 to round up, 0 to round down. Always a nice little function to have lying around
  6. Do you have PHP5 installed on the server?
  7. Look into Cronjobs would be my suggestion
  8. The problem is'nt in the cookie, it has been set right, the problem is in the information you're trying to check before setting the cookie - you've added the line: $row = mysql_fetch_array($result) or die(mysql_error()); But you're forgetting the "while" statement to create the area that information can be used it, try something like this: //Include mklib.php and main_style.css and connect to the database include "../engine/mklib.php"; connect(); //Start Code if (!isset($_POST[submit])) { $show_form = "yes"; } elseif (isset($_POST[submit])) { $query = "SELECT * FROM admins WHERE f_name = '$_POST[f_name]' AND l_name = '$_POST[l_name]' AND password = '$_POST[password]'"; $result = mysql_query($query) or die(mysql_error()); $check_row = mysql_num_rows($result); if ($check_row != 1) { $error = "This Administration record is not found. And/Or name and password do not match."; $show_form = "yes"; } else { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $value = $row[adminID]; if ($row[auth_lvl] == "SA") { setcookie("sa", $value, time()+1800, "/", "rdrvision.com", 0); $display = "You are logged in <a href = 'control_panel.php'>Go to Control Panel</a>."; } elseif ($row[auth_lvl] == "GM") { setcookie("admin", $value, time()+1800, "/", "rdrvision.com", 0); $display = "You are logged in <a href = 'control_panel.php'>Go to Control Panel</a>."; } } mysql_free_result($result); } } //end if Otherwise it looks fine.
  9. echo("<td width=10% align=middle><a href='project_details.php?id=".$row["project_id"]."'><img src=\"images/viewer.ico\" border=\"0\"></a>");
  10. Try this: $recipients = "onerecip|".rawurldecode($_GET['mail']); Seems like the browser could be encoding the value of $mail to handle it.
  11. If its for some kind of forum flood control you don't actualy need any kind of timer, try something like this: Add a "last post" feild to the user table then when they make a post have it ammend the current time to the feild and each post after just check against it with the current time and if the difference is only a few seconds/minutes (depending on what you want) don't save the post to the DB. Hope that makes sense
  12. use a switch statement in your content area like so: <?php $content = $_GET['content']; switch ($content){ case "catalog": include("catalog.php"); break; case "page2": include("page2.php"); break; case "page3": include("page3.php"); break; default: include("catalog.php"); } ?>
  13. Can we see the site? this seems like a flash problem and not a php problem..
  14. Try this: <?php include 'connect.php'; if(isset($_GET['id'])) { $id = $_GET['id']; $new = '0.00001'; $mdata = mysql_query("SELECT * FROM users WHERE id='$id'"); while ($row = mysql_fetch_array($mdata, MYSQL_ASSOC)) { $old = $row['earn']; } $total = $old + $new; echo $id; echo '<br><br>'; echo $old; echo '<br><br>'; echo $new; echo '<br><br>'; echo $total; } mysql_free_result($mdata); ?> Not completely tested (i.e - i didn't create a db, i manualy inputted the value of $old) but it should work!
  15. i was just popping in a anything just as an example.
  16. I beleive this is done with frames and/or java and php's involvement is strictely to supply the data held within the frame.
  17. now() doesn't exist natively to php, it exists in MYSQL though. Here are two possible solutions, one for PHP and one for MYSQL (depending on what you actualy want): - PHP $time = time() + (0 * 12 * 00 * 00); - MYSQL DATE_ADD(NOW(), INTERVAL 12 HOUR) Hope this helps
  18. Hooker

    arrays?

    Heya, Ive been wondering how to do this for a fair while now and im sure its easy to do but im not 100% sure what im even looking for when looking for tutorials, basicaly im writing an events calander but when an event is made registerd users will be added to it by the creator. So say i select i wanted 8 staff to go on a trip and each staff member can supervise 8 people, the forum would generate 8 columns with drop down boxes listing all the possible users (top box being the staff member) then it'd add all that information to the db and it'd be easily pulled out so everyone can see, ive got all the tables sorted: // Divers personal information. DROP TABLE IF EXISTS `Divers`; CREATE TABLE IF NOT EXISTS `Divers` ( `Diver_id` int(3) NOT NULL auto_increment, `Title` varchar(4) default NULL, `Forename` varchar(32) default NULL, `Init` varchar(1) default NULL, `Surname` varchar(32) default NULL, `ADDR1` varchar(32) default NULL, `ADDR2` varchar(32) default NULL, `ADDR3` varchar(32) default NULL, `ADDR4` varchar(32) default NULL, `ADDR5` varchar(32) default NULL, `Postcode` varchar(8) default NULL, `Tel1` varchar(15) default NULL, `Tel2` varchar(15) default NULL, `Mobile` varchar(15) default NULL, `Email` varchar(50) default NULL, `Padi_Level` varchar(20) default NULL, `Hol_ADDR1` varchar(32) default NULL, `Hol_ADDR2` varchar(32) default NULL, `Hol_ADDR3` varchar(32) default NULL, `Hol_ADDR4` varchar(32) default NULL, `Hol_ADDR5` varchar(32) default NULL, `Hol_Tel` varchar(15) default NULL, `Next_Kin` varchar(30) default NULL, `DOB` varchar(8) default NULL, `Staff` varchar(8) default NULL, PRIMARY KEY (`Diver_id`,`Forename`,`Surname`,`Postcode`), ) TYPE=MyISAM; // Events, set in the calander DROP TABLE IF EXISTS `Event_log`; CREATE TABLE IF NOT EXISTS `Event_log` ( `Event_id` int(3) NOT NULL auto_increment, `Date` date NOT NULL default '0000-00-00', `Activity` date NOT NULL default '0000-00-00', PRIMARY KEY (`Event_id`,`Date`,`Activity`), ) TYPE=MyISAM; // Dive logs, this matches divers to dives and checks if theyre staff for that event. DROP TABLE IF EXISTS `Divers_log`; CREATE TABLE IF NOT EXISTS `Divers_log` ( `Diver_ID` varchar(15) default NULL, `Event_ID` varchar(15) default NULL, `Diver_Level` varchar(15) default NULL, PRIMARY KEY (`Diver_ID`,`Event_ID`,`Diver_Level), ) TYPE=MyISAM; its for a diving community i belong too, basicaly the info from all the other divers is kept in one table, the events are kept in another and then theres a third table that matches them all up, ive got all that down im just wondering about the input. ive been looking into ajax etc to do this sort of thing without refreshing the form but again im not entirely sure what im looking for. any links to tutorials/examples would be greatly appreciated
  19. Im taking over development for a friends site that was all html in the past, he has about 1000 pages of html news and doesnt want to loose anything in the transfer to php, obviously i dont want to spend a few days/weeks going through each seperate html file copy and pasting bits from old news articles so i was thinking about using something along the lines of preg_replace, ive used it a couple of times for things like bb code because the only things that seem to stay constant in the files are the tags around things like "posted by" and "date" etc so i was thinking something like this: (the source would be copied and pasted into a form then this would process it) [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] $output = file("$_POST['input']"); $output = explode("|", $output); $find = array( "'\[b\](.*?)\[/b\]'is", "'\[link\](.*?)\[/link\]'i", "'\[link=(.*?)\](.*?)\[/link\]'i" ); $replace = array( "<strong>\\1</strong>", "<a href=\"\\1\">\\1</a>", "<a href=\"\\1\">\\2</a>" ); preg_replace($find,$replace,$output); echo $output[1];[/quote] obviously this is just a quick example of a way to process BB code, my question is - is there anyway to save the value of the "(.*?)" 's to a csv file or a txt file so i can load it into a db onces theyre all processed? thanks in advance.
  20. hrm maybe you can show us the code so we can take a quick look through it?
  21. [code] value=<?php echo $_SERVER['PHP_AUTH_USER'];  ?> [/code]
  22. It looks like your better off finding a different script or writing your own, even their demo site is having sql problems (probably updated their php/mysql without updating the script to match) if you try somewhere like hotscripts im sure theres a bunch of newer scripts around if you dont want to write your own.
  23. Try This: [code]<?php $hostname = localhost; $username = *******_***; $password = ********; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $connection = mysql_select_db($database_conn, $conn); $query = "SELECT name, age, gifts, about FROM Stories"; $mysql_result=mysql_query($query,$conn); echo("<table>"); while ($rows = mysql_fetch_array($mysql_result)){ echo(" <tr> <td><b>Name</b><td>" . $rows['name'] . " <tr><td><b>Age</b><td>" . $rows['age'] . " <tr><td><b>Gifts and Talents</b><td>" . $rows['gifts'] . " <tr><td><b>More about " . $rows['name'] . "</b><td>" . $rows['about'] . "</tr>"); } echo("</table>"); ?>[/code] you cant output raw html within the <?php ?> tags, you need to echo them, also advanced warning: make sure to \ any " or ' within echos like this: [code]<?php echo("Foo \"Bar\""); ?>[/code] to avoid any parse errors - sorry if the code is kinda messey, i was in a rush :)
  24. Switch case statements are generaly used on one variable, i think the problem you have here is more down to script planning than anything, try using an array to hold the information (or a database) in a single variable that can be processed by the same function, failing that heres a couple of ways to do it: [code]<?php $i = "50";   // set the value of the variable echo ($i >= 70) ?  "passed" :   // check if the value of variable $i is above 70 and output "passed"     (($i <= 70) ?  "failed" : "")); // check if the value of variable $i is below 70 and output "failed" ?>[/code] although if you're trying to learn about switch case statements, heres a quick example: [code]<?php $i = "50"; switch ($i) {   case ($i <= 70):      echo "failed";   break;   case ($i >= 70):      echo "passed";   break;   default:      echo "no input!";   break; } ?>[/code] both examples work pretty much the same way and both written off the top of my head so excused me if ya pick out the odd miss-placed "(" :P anyway as you can see most switch case statements will use one variable and compare its contents to pre-set values (the cases) then if it finds it it outputs everything up to the next "break" or "case" at which point it will either check the value again or stop the output, if there is no value or the value of the variable doesnt match any of the case's you can set a default output (as seen above) so you dont have a completely empty output, hope this helps!
  25. Generally, PHP files will get interpreted by the Web server and PHP executable, and you will never see the code behind the PHP file. If you make the file extension .PHPS, a properly-configured server will output a color-formated version of the source instead of the HTML that would normally be generated.
×
×
  • 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.