Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Philip

  1. Never, and there should never be a reason to. If you are the site administrator you should have full access to the site/server's control panel/root account, thus having access to everything you need. If it's for a client, it must be stated in the contract - I always just give myself an admin account so if they need help it's 2 clicks away for me.
  2. It would show as the last row --- It's good practice and correct syntax to have the quotes around the key, otherwise PHP will look for a constant with the name "content" first, then assume you meant with the key name "content" --- @OP: whew, I don't know where to start on this one. A few things I see right off the bat. - No need for the loop if you're just going to limit the query to 1 result. - No need to echo out the entire header of the page, just for the title - There is no attribute for a table with "bordercolor" (use style="...") With that being said, here is the updated code: <?php include('includes/connect.php'); $sql=("SELECT * FROM `tbl_content` WHERE `page_id` = '" . $_GET['page_id'] . "' LIMIT 1"); $result=mysql_query($sql); if(mysql_num_rows($result)==0) { die("Database problems!"); } $row = mysql_fetch_array($result); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Project Renovations | <?php echo $row['title'];?> </title> <link rel="stylesheet" href="css/template_css.css" type="text/css" /> <link rel="shortcut icon" href="images/favicon.ico" /> </head> <body> <div align="center"> <table align="center" width="600px" style="border: 2px solid #000066;" > <tr><td><table> <tr><td valign="top"> <div id="header"> <div id="nav"> <?php include_once('includes/nav_menu.php'); ?> </div> </div> </td> </tr> <tr><td align="right"> </td> <tr> <td><div id="content"> <div> <div id="maintext"> <?php echo($row['content']); ?> </div> <div id="randomgallery"> <?php include "randomimage.php"; ?> </div> </div> </div></td> </tr> </table> </tr></tr></table> </div> </body> </html> Now, if you still aren't getting content, replace echo($row['content']); with: echo '<pre>'; print_r($row); echo '</pre>'; and copy/paste the results here.
  3. You wouldn't need to use the check_input function on the age check. You could also use intval()
  4. if (is_numeric($age > 16 && $age < 26)) that is incorrect syntax if (is_numeric($age) && $age > 16 && $age < 26)
  5. When variables and other certain values (like \n) are in single quotes they will not be parsed, just read how you see them. In other words, $message = '$name /n $email /n $school /n $diet'; should be: $message = :"$name /n $email /n $school /n $diet";
  6. Google is your friend, first one off the list: http://www.micahcarrick.com/04-19-2005/php-zip-code-range-and-distance-calculation.html
  7. Haha, nahhhh Btw, @OP: never use short tags (<?) - always use <?php. This will guarantee that your script will be [mostly] compatible across servers, as in PHP 5 the short tags are disabled by default and PHP 6+ they will be deprecated
  8. You're not initializing the class (where is $params coming from?)
  9. Also, using quotes around the key is good practice - otherwise it'll look for that constant first, then automatically assume 'id' instead. <?php include 'connection.php'; if(!isset($_GET['id']) || empty($_GET['id'])) { // if there was no id in the url, or it was empty kill the script die('Invaild script parameters!'); } $query = "SELECT * FROM `test` WHERE ID = '".$_GET['id']."'"; $result = mysql_query($query); $post = mysql_fetch_array($result); ?> Make sure $_GET['id'] is getting set & has a value.
  10. The only thing I can see is when viewing the source an unwanted character appears... see screenie for details. Check your script to make sure there aren't any extra spaces outside your <?php ?> tags [attachment deleted by admin]
  11. $link = mysql_connect($host, $user, '$password); no { needed, just a ;
  12. Can you post your current code? Here's what I have for you, more organized IMO - also read the comment about the while loop, it should make your code easier <?php function HandleOutstandingSendSuccesses ($user) { global $logsend_table; global $facebook; global $db_to_desc_send; //$rx_money = false; $result = Query ("SELECT id,uid_from,what,amt FROM $logsend_table WHERE uid_to=$user and notified='0' and trade=0"); $num_rows = mysql_num_rows($result); // Why not use mysql_fetch_assoc here instead of the for( ) loop? // Below is an example: /* while($row = mysql_fetch_array($result)) { $uid_from = $row['uid_from']; $what = $row['what']; // ... etc // run your try/catch and messages } // end loop for each row fetched */ for ($i=0; $i<$num_rows; $i++) { $uid_from = mysql_result($result, $i, "uid_from"); $what = mysql_result($result, $i, "what"); $amt = mysql_result($result, $i, "amt"); $id = mysql_result($result, $i, "id"); try { $info = $facebook->api_client->users_getInfo ($uid_from, "name"); } catch (FacebookRestClientException $e) { $info = ""; } //$persons_name = $info[0]['name']; $persons_name = isset ($info[0]['name']) && $info[0]['name'] != "" ? $info[0]['name'] : "Someone"; if ($what == "money") { //$rx_money = true; $amt_f = sprintf ("%.2f", $amt/100); ?> <fb:success message="WOW!!!! <?php echo $persons_name;?> just sent you $<?php echo $amt_f;?> airfarebucks!" /> <?php } else { $prize_f = $db_to_desc_send[$what]; ?> <fb:success message="WOW!!!! <?=$persons_name;?> just sent you <?=$amt;?> of the following prize: <?=$prize_f;?>" /> <?php } Query("UPDATE $logsend_table SET notified=1 where id=$id"); } } // end function function HandleCoupons ($user) { global $users_table; $result = Query ("SELECT sum(coupon1) FROM $users_table WHERE uid=$user and coupon1_notified='0'"); if(mysql_result($result, 0) > 0) { $result_new = Query ("UPDATE $users_table SET coupon1_notified='1' where uid=$user"); } return mysql_result($result, 0); } ?>
  13. I'd use array_combine() $users = '1;7;5;3;6;2'; $users = explode(";", $users); $points = '10;12;8;11;8;9'; $points = explode(";", $points); $array = array_combine($users, $points); // combine, use users as key, $points as value arsort($array); // sort, maintaining the correct keys, from highest to lowest points echo '<pre>'; print_r($array); // show what outputs echo '</pre>'; Outputs: Array ( [7] => 12 [3] => 11 [1] => 10 [2] => 9 [5] => 8 [6] => 8 )
  14. I think you should do something like if your prospective clients were walking into your code/a webpage. Kinda like http://css-tricks.com/0404 Just a basic idea.
  15. Why didn't I think of it like that
  16. <?php $totalPlayers = 83; // # of people $seatsPerTable = 10; // # of seats at each table $tableNum = ceil($totalPlayers/$seatsPerTable); // # of tables $maxTables = ($totalPlayers%$seatsPerTable); // # of tables that are maxed out $table = array(); // setup table array for($currentTable=1, $currentPlayer=1; $currentTable<=$tableNum; $currentTable++) { // Loop through each table if($currentTable==$maxTables) { // If the current table is equal to the number of tables with max players, // we need to subtract 1 from the seat count on the rest of the tables $seatsPerTable--; } for($currentSeat=1; $currentSeat<=$seatsPerTable; $currentSeat++,$currentPlayer++) { // Loop through each seat $table[$currentTable][$currentSeat] = 'player #'.$currentPlayer; } } $totalSeats = $currentPlayer-1; // We have to adjust for the last loop (still adds 1) // Show results: echo 'Seats used: ',$totalSeats,'<pre>'; print_r($table); echo '</pre>'; ?> Tested. However, not sure if it's what you want though. Just to show output here: Seats used: 83 Array ( [1] => Array ( [1] => player #1 [2] => player #2 [3] => player #3 [4] => player #4 [5] => player #5 [6] => player #6 [7] => player #7 [8] => player #8 [9] => player #9 [10] => player #10 ) [2] => Array ( [1] => player #11 [2] => player #12 [3] => player #13 [4] => player #14 [5] => player #15 [6] => player #16 [7] => player #17 [8] => player #18 [9] => player #19 [10] => player #20 ) [3] => Array ( [1] => player #21 [2] => player #22 [3] => player #23 [4] => player #24 [5] => player #25 [6] => player #26 [7] => player #27 [8] => player #28 [9] => player #29 ) [4] => Array ( [1] => player #30 [2] => player #31 [3] => player #32 [4] => player #33 [5] => player #34 [6] => player #35 [7] => player #36 [8] => player #37 [9] => player #38 ) [5] => Array ( [1] => player #39 [2] => player #40 [3] => player #41 [4] => player #42 [5] => player #43 [6] => player #44 [7] => player #45 [8] => player #46 [9] => player #47 ) [6] => Array ( [1] => player #48 [2] => player #49 [3] => player #50 [4] => player #51 [5] => player #52 [6] => player #53 [7] => player #54 [8] => player #55 [9] => player #56 ) [7] => Array ( [1] => player #57 [2] => player #58 [3] => player #59 [4] => player #60 [5] => player #61 [6] => player #62 [7] => player #63 [8] => player #64 [9] => player #65 ) [8] => Array ( [1] => player #66 [2] => player #67 [3] => player #68 [4] => player #69 [5] => player #70 [6] => player #71 [7] => player #72 [8] => player #73 [9] => player #74 ) [9] => Array ( [1] => player #75 [2] => player #76 [3] => player #77 [4] => player #78 [5] => player #79 [6] => player #80 [7] => player #81 [8] => player #82 [9] => player #83 ) )
  17. $insertport is what you're trying to call, it should be $insertpost
  18. You really charge that much? Dammnnnnnnn! I'm living in the stone ages where I live I guess. $30/hr is reasonable around here
  19. A great tutorial on our site about pagination: http://www.phpfreaks.com/tutorial/basic-pagination
  20. Change: header('Location: http://www.exampleurl.com/files/$filename'); to header('Location: http://www.exampleurl.com/files/'.$filename);
  21. Ehh, I would be careful running a script that long. Although the script might be "sleeping" it is still having to use resources, and can cause overload on a server - especially if you're doing it for 60 minutes, every hour (making it run 24/7)
  22. Depending on if your traffic size is large enough, you could have each page load simply run one or two emails - then whatever is left over, the cron would take care of.
  23. I wouldn't run it every minute. A lot of hosts (and I'm surprised GoDaddy doesn't do this) limit the crons to every 10-15 minutes. This helps from users overloading their servers by running resource intensive scripts every single freakin' minute. Now, I don't know how to setup a cron job via PHP - in fact I don't know how possible it is running it off a shared host. From what it sounds like, running a cron every 10-15 minutes should be fine. When it's running, just have it look for a message time within the past 10-15 minutes, and then you could delete that row (or set a flag saying message sent)
  24. and line 2 <?php $undecided = 3.14; echo "Is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'string'); echo "Is " .$undecided. " a string? " .is_string($undecided). "<br />"; // string settype ($undecided, 'integer'); echo "is " .$undecided. " an integer? " .is_int($undecided). "<br />"; // integer settype ($undecided, 'double'); echo "is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'bool'); echo "is " .$undecided. " a boolean? " .is_bool($undecided). "<br />"; // boolean ?> Although, I would take a look at this comment
  25. Well why are you using the user's name as a field in your table....that really makes no sense to me, instead of just having a field called username and storing it there. Anyhow, if KingPhilip's worked, then yea that is how your table is designed. Weird, but I guess it works for you. His table setup is fine, he was just doing: value = column instead of column = value like we are used to seeing
×
×
  • 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.