Jump to content

Perad

Members
  • Posts

    287
  • Joined

  • Last visited

    Never

Everything posted by Perad

  1. hmm yes so it would. Have you got any ideas on how to address this?
  2. - Top of the page - In my actual script. [code]$postdate = strtotime($dbentry['postdate']); $date = date('j F Y, g:i a', $postdate); //Currently does very little $date = timezone($date);[/code] My function [code] function timezone($date) { global $userdata; $timezone = $userdata['user_timezone']; $serverTime = "1.0"; $difference = ($timezone - $serverTime); $date -= ($difference * 3600); $ourTime = date('d/m/Y h:i:s',$date); echo $ourTime; }[/code] The function is supposed to take the date variable and convert it to the users timezone. Currently when i run it, there are no errors but the output is the 1/1/1970 time, instead of the current time +/- an hour. $timezone is a decimal 1.0, 2.0, based on how far ahead or behind GMT the user is.
  3. Ah thanks for that, i missed that. My question was more towards how i actually subtract the time from the database entry. How do i subtract 1.0 (1 hour) from 2007-01-22 01:44:06?
  4. Sorry can't find edit button. Thought i should mention that times being changed are using the postdate database type.
  5. My original server was based in England and i completely missed the fact that different people in different time zones will be stuck with the wrong times. As a result i am creating a function to wrap around all of the postdates. i.e. timezone($time) I have this so far [code]function timezone() { $timezone = $userdata['user_timezone']; $serverTime = "1.0"; $difference = ($serverTime - $timezone); }[/code] The database stores timezones in decimal format. So GMT is 0.0, GMT+1 is 1.0. The $difference generates what needs to be subtracted from the time to get to the users time zone. So... GMT would give you. 1.0 - 0.0 = 1.0. Time - 1.0 will get you to the GMT. As for the final step. How do i add the time aspect to add/subtract the $difference variable?
  6. I just have 2 questions really. When you make a post on the forum, is the servers time saved to the database? Or is it the time on your computers clock? Secondly does anyone know of any good articles that explain how to add and subtract time. Mainly hours.
  7. Do you want to post what you have, its hard to blindly guess. If it works in IE, check the output code. Firefox doesn't process php, it processes what php outputs so logic would suggest that the problem is with that.
  8. OK, i am not too sure how this works and i am looking for some advice. I want to add a [player] [/player] BBcode. '/\[player\](.*?)\[\/player\]/is',  Now, i want to convert the player name into the players ID by querying my database. I will then create a link <a=(link)(user_id)>(playername)</a> Does anyone have any idea how i would do this and where i put my db query? Can this even be done with my current script? [code]<?php function bbcode_format ($str) { global $dbc; $str = $str; $simple_search = array( '/\[b\](.*?)\[\/b\]/is',                                '/\[i\](.*?)\[\/i\]/is',                                '/\[u\](.*?)\[\/u\]/is',                                '/\[url\=(.*?)\](.*?)\[\/url\]/is',                        '/\[url\](.*?)\[\/url\]/is',                            '/\[align\=(left|center|right)\](.*?)\[\/align\]/is',    '/\[image\](.*?)\[\/image\]/is',                            '/\[email\=(.*?)\](.*?)\[\/email\]/is',                    '/\[email\](.*?)\[\/email\]/is',                            '/\[font\=(.*?)\](.*?)\[\/font\]/is',                    '/\[size\=(.*?)\](.*?)\[\/size\]/is',                    '/\[color\=(.*?)\](.*?)\[\/color\]/is', '/\[player\](.*?)\[\/player\]/is',        ); $query = "SELECT user_id FROM unc_users WHERE username='$1'"; $result = mysql_query ($query)or die("Problem with the query: $query on line:" . __LINE__ . "<br>" . mysql_error()); $simple_replace = array( '<strong>$1</strong>', '<em>$1</em>', '<u>$1</u>', '<a href="$1">$2</a>', '<a href="$1">$1</a>', '<div style="text-align: $1;">$2</div>', '<img src="$1" />', '<a href="mailto:$1">$2</a>', '<a href="mailto:$1">$1</a>', '<span style="font-family: $1;">$2</span>', '<span style="font-size: $1;">$2</span>', '<span style="color: $1;">$2</span>', '<strong>$1</strong>', ); // Do simple BBCode's $str = preg_replace ($simple_search, $simple_replace, $str); // Do <blockquote> BBCode $str = bbcode_quote ($str); return $str; }[/code]
  9. Ah thank you so much, i made one slight tweak ($i < 4) But yeah, thanks a lot  8)
  10. This is the final bug in my site and hopefully the last time i will need help. I have a "latest news" bar which needs 5 articles to float what is to the right of it. If there are less than 5 articles it cannot float the images to the right and my page breaks. What i want it to do is check to see if there are 5 articles. If there are less than 5 i want it to fill up the difference with echo "<div class=\"news1\"><span>Empty</span></div>"; Could someone talk me through how i could adapt the script below to make it do this please. [code]function latestnews() { global $db, $max_items; $query = "SELECT id, title, cat_id, postdate FROM news ORDER BY postdate DESC LIMIT 5"; $result = mysql_query ($query) or die("Problem with the query: $query on line:" . __LINE__ . "<br>" . mysql_error()); echo '<div class="newscontainer">'; while ($row = mysql_fetch_assoc ($result)) { $postdate = htmlentities ($row['postdate']);      $title = htmlentities ($row['title']); //Display Data echo "<div class=\"news1\"><span> <div class=\"left\">$title</div> <div class=\"right\"><a href=\"../UNC/index.php" . "?action=show&id=".$row['id']."\">More</a></div></span></div>";   } echo '</div>'; }[/code]
  11. I have seen it done with headers but this is needed half way down my script and it keeps saying "headers have already been sent." Currently i have this code. My client though doesn't want to have verification, instead he just wants the page to redirect itself when the comment has been posted. echo "<div class=\"confirmation\">Comment entered. Thanks!\n"; echo "<a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id=$id\">Back</a></div>\n"; How can i edit this to make it go directly to the link?
  12. Right, i have an admin query. [code] global $dbc, $user_id, $uncaccess; $adminaccess = 0; $query = "SELECT user_id=$user_id FROM unc_user_group WHERE group_id=2;"; $result = mysql_query($query)or die(mysql_error());; $row = (mysql_fetch_assoc ($result)); if (($row['user_id='.$user_id])==1) { $uncaccess = 1; echo '<a href="folder/admin.php">Admin Control Panel</a>'; } else { $uncaccess = 0; }[/code] This is simply used to display a link to the admin panel. The idea simply is to simply check against the forums user group to see if you fall into the admin category. The problem with this is that if you are in more than one group the test often fails. For example. My top admin account gets the following back from the query 1 0 My secondary admin account gets out 0 1 The query interprets the second user as not having admin privileges $user_id simply gets the users id. This is then checked against the following table. group_id  user_id  user_pending 1            -1 0 Could someone help me fix this query so that it always finds the number 1 no matter what order the numbers come out in.
  13. I have an array which contains the names on an input form and image names. [code]$maps["Beltot"] = "beltot.jpg"; $maps["Brecourt"] = "brecourt.jpg"; $maps["Burgundy"] = "burgundy.jpg"; $maps["Caen"] = "caen.jpg"; $maps["Carentan"] = "carentan.jpg"; $maps["El Alamein"] = "elala.jpg"; $maps["Leningrad"] = "leningrad.jpg"; $maps["Matmata"] = "matmata.jpg"; $maps["Moscow"] = "moscow.jpg"; $maps["Rostov"] = "rostov.jpg"; $maps["St.Mere Eglise"] = "stmere.jpg"; $maps["Stalingrad"] = "stalingrad.jpg"; $maps["Toujane"] = "toujane.jpg"; $maps["Villers-Bocage"] = "villers.jpg"; $maps["Wallendar"] = "wallendar.jpg";[/code] I have called the values from the database. [code]$map1 = $row['map1']; $map2 = $row['map2'];[/code] How do i compare $map1 with the $maps array to find the right image?
  14. Ah thats perfect thanks, i just couldn't work out where the variable $postdate fitted in the date function. Cheers for the help guys
  15. I am using datestamp in my 'postdate' db field. When someone enters a post the postdate is stored. How do i format a variable with the date function? I can't work out where the variable goes. This is what i have... [code] $postdate = strtotime($row['postdate']); $postdate = date("j F, Y, g:i a"); [/code] Help on this is very much appreciated. EDIT: I am trying to get to display -- Day Month Year : Time
  16. When i create a news article for my site i have the following code mysql query. [code]$query = "INSERT INTO news(postdate, title, newstext, cat_id, author, author_id) VALUES(NOW(), '$t', '$c', '$a_cat', '$username', '$user_id')";[/code] When i edit a news article i have the following query. [code]$query = "UPDATE news SET title='$t', newstext='$c' WHERE id='$id'";[/code] Yet it always changes the postdate as well. Is there a way in which i can update my mysql table without the postdate column being updated as well?
  17. The easiest way is to install apache, mysql and php on your computer. This will make your computer a web server and thus make development very fast. The second way is to get a web host that has php and mysql. You can then update stuff as you go along. The problem with this is that development is slow as you have wait for it to upload before you fix errors. To upload data you can use IE6 or a more advanced ftp client.
  18. This is to make an order system for my website, I was trying to make a script which moved things up and down but found it to hard when people added and removed new groups. In this it will print out each group with an order number. When you submit it i will check that all numbers are consecutive and not the same then i will enter the new orders into my database. I am just having troubles storing all the values in the array. [code] <? function ordergroup () { function arrange (){ echo '<form action="admin_members.php' . '?action=reorder" method="post">'; $membername = $_POST['membername']; $query = "SELECT * FROM uncgroupss ORDER BY group_order"; $result = mysql_query ($query); while ($row = mysql_fetch_assoc ($result)) { $groupname = $row['group_name']; $grouporder = $row['group_order']; echo 'Name: '.$groupname.' :: Current Order ::&nbsp;<input name="'.$groupname.'" type="text" size="3" maxlength="3" value="'.$grouporder.'" /><br />'; } echo '<input type="submit" name="submit3" value="Search"></form>'; } function reorder () { $numbercount = 0; $query = "SELECT group_name FROM uncgroupss ORDER BY group_order"; $result = mysql_query ($query); while ($row = mysql_fetch_assoc ($result)) { $name = $row['group_name']; $valuearray[] = $_POST[$name]; $namearray[] = $name; $numbercount++; }   echo '<pre>' . print_r($valuearray,true) . '</pre>'; } switch($_GET['action']) { case 'arrange': arrange(); break; case 'reorder': reorder(); break; default: arrange(); } }?>[/code]
  19. Ah thanks a lot for the tip, the problem is with a form which has the name "web master" It isn't showing up. Would that be because "$_POST[$name];" doesn't interpret spaces?
  20. I am still getting my head around arrays. I have this function, when i echo out the array values it only records the last value. [code] function reorder () { $query = "SELECT group_name FROM uncgroupss"; $result = mysql_query ($query); while ($row = mysql_fetch_assoc ($result)) { $name = $row['group_name']; $valuearray[] = $_POST[$name]; } echo $valuearray[1]; echo $valuearray[2]; echo $valuearray[3]; }[/code] I must be copying over the original value in the while statement. How can i tweak this to make it work?
  21. I have this [code]INSERT INTO unc_members (userid, unc_group) VALUES ($id, $group)[/code] What i want to do is check to see there is a there is an existing value for the userid. If there is I want to update the value? Can i do this with SQL? Or have a got to use PHP?
  22. Ah of course. Its been a long day, thanks a lot  :D
  23. if (empty($_POST['first_name'])) { This is ignoring zero's. Does anyone know of anything which checks to see if the submit box is empty yet perceives zero as a value.
×
×
  • 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.