Jump to content

final60

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by final60

  1. I am modifying some javascript for Google maps so that the different pin information is retrieved from my database. If I was to do this with just php it would be like this: <?php while($row = mysql_fetch_assoc($query)) {$title = $row['title']; $desc = $row['desc']; echo 'This '.$title .' and this '. $desc .';}?> If there were 5 rows in the database there will be five lines with 5 different titles and descriptions. But I have this line of javascript that I would like to be in a while loop: map.addMarkerByLatLng(37.8685, -1.5108, "Sanatario de Terburculosos", createInfo("title goes here","")); How can i write it so that that javascript is in a php while loop or how can i do the javascript equivelant of the php while loop so that i can retrieve multiple rows of lang,lat info each in its own javascript code like above? Thank you.
  2. for some reason when i empty the tables and start creating new posts it displays them properly until I create say the 8th or 9th post in that category and then it shows the duplicate error. but im not sure how it would duplicate if the post_id's are all unique whihch keeps each row unique in the is_read table which consists of post_id, user_id ,is_read (0/1).
  3. Hi Im receiving this error using the following mysql statement: SELECT posts.title, posts.content, posts.date, (SELECT user.username FROM urbex_users AS user WHERE user.user_id = posts.user_id) AS username, (SELECT count(reply_id) FROM urbex_forum_replies AS rep WHERE rep.post_id = posts.post_id)AS replies, cat.category_name, posts.sticky, posts.post_id, is_read.post_id, (SELECT is_read.is_read FROM urbex_forum_posts_is_read AS is_read WHERE posts.post_id = is_read.post_id AND is_read.user_id = 14) AS is_read, posts.user_id FROM urbex_forum_posts AS posts, urbex_forum_categories AS cat, urbex_forum_posts_is_read AS is_read, urbex_users AS users WHERE posts.category_id = cat.category_id AND posts.post_id = is_read.post_id AND posts.user_id = is_read.user_id AND users.user_id = posts.user_id AND posts.sticky = 0 AND cat.category_id = 1 ORDER BY posts.date DESC I checked the tables and as far as I can see there are no duplications anywhere. post_id is the pk for posts table which would make everything all posts unique in both the posts table and the is_read one? When a new post is created a new entry is made in both the posts table and the is_read table. The query works fine when I remove the is_read sub query. But I need it to tell the user when a new post or reply has been made.
  4. DOH found i. Always the little things I miss grrrr. I forgot to repeat the catid and catname in the ternary operator..
  5. Hi Im using basic pagination to split up forum threads. For some reason when a page link is clicked the GET info is not passed in the url and the page number is: $per_page = 5; $page_query = mysql_query("SELECT count(post_id) FROM urbex_forum_posts"); $pages = ceil(mysql_result($page_query, 0) / $per_page); $page = (isset($_GET )) ? (int)$_GET['page']: 1; $start = ($page - 1) * $per_page; if($pages >=1 && $page <=$pages) { for($x=1;$x<=$pages;$x++) { echo $_GET['cat_id'].' '.$_GET['cat_name']; $cat_id = $_GET['cat_id']; $cat_name = $_GET['cat_name']; echo ($x == $page) ? '<a href="?cat_id='.$cat_id.'&cat_name='.$cat_name.'&page='.$x.'">['.$x.']</a>' : '<a href="?page='.$x.'">'.$x.'</a>'; } } $query2 = mysql_query("query...."); ... thanks for any help.
  6. It is just the single form. the cat_id is passed to the page in the url which i was trying to input directly using GET in the mysql_query which wouldnt work, I also tried putting the cat_id in a variable first but nada. Ive changed it to using a hidden input field with the cat_id echoed into its value which works fine, but would have rather not done that.
  7. yeah its frustrating. I just used a hidden input type with the cat_id echo into it and it submits the data fine that way, but that doesnt solve the issue really :/ I Appreciate your efforts..
  8. No, sorry I shoul dhave been clearer (edited previous post too late) it echos 1, but when i try to insert that in the database it always enters 0
  9. it is set as int(11) when echo'd on the page it displays 1.
  10. Hi, Im having a problem with inserting my forum category id into the datase when a new forum post is submitted. Heres part of the markup $cat_id = $_GET['cat_id']; if(isset($submit) && ($title != 'Title') && strlen($title)>5) { if(!empty($title) ) { if(!empty($content) && ($content != 'Enter your post content here..') && strlen($content)>9) { mysql_query("INSERT INTO urbex_forum_posts (user_id,title,content,date,sticky,category_id) VALUES('$_SESSION[urbex_user_id]','$title','$content',NOW(),'0','$_GET[cat_id]')"); }else{ echo "<p>Could not process post: Please make sure the content is atleast 10 characters!</p>"; } }else{ echo "<p>Could not process post: Please make sure the title is atleast 6 characters!</p>"; } } When I use both $cat_id or just $_GET['cat_id'] both submit 0 into the cell in the database table. When I echo both out on the page the both echo the correct category name.
  11. thanks that helped alot would the foreach have worked just out of interest?
  12. is this in the right direction? Ive not yet started using foreach loops but it seems the right kind of thing. SO when a new post or reply is created something similar to this code is used $users = mysql_query("SELECT user_id FROM urbex_users"); foreach($users as $each_user) { mysql_query("INSERT INTO urbex_forum_posts_is_read AS is_read (post_id,user_id,is_read)VALUES("$_GET[post_id]","$each_user","0")"); } and when the user views the post it sets is_read back to 1 mysql_query("UPDATE urbex_forum_posts_is_read SET is_read='0' WHERE post_id='$_GET[post_id]' AND user_id='$_SESSION[urbex_user_id]'"); not sure if im barking up the right tree tbh
  13. Hi Im currently coding a simple php/mysql forum and am stuck on how to alert the user when a someone has replied to a post on the fourm. Currently I have the following tables: forum_posts post_id pk user_id title content date is_sticky cat_id forum_replies reply_id pk user_id reply_date reply_content post_id post_is_read post_id user_id is_read (0/1) SO far Ive thought that the best way to do it is when a new post is created a row is made in post_is_read for all users with is_read set to 0. Then a text can be displayed saying "new post". Then when the user views the post the row that is equal to their username, the post_id has the is_Read set to 1. Then when a new reply is made on the post it sets is_Read back to 0 for all users again. But How do I first retrieve each user_id from users table and insert a new row in is_read table with post_id, user_id, is_read=0 for each user? Is there a better way to do the whole thing ? thanks for any help
  14. Thanks. dammit what an idiot! and yup ill do encryption etc as next step!
  15. Hello I am using a farely basic login script for my site. But for some reason sometimes when I logout and try to log back in it will not let me login even though the login details are correct. If I then register with new login details it will let me login with those details but no previous ones. I just can't figure this out. Here is this code login.php <form name="login_form" action="login2.php" method="post"> <table> <tr><td><input type="text" name="username" id="login_fields" value="" /></td><td><input type="password" name="password" id="login_fields" value="" /></td><td><input type="submit" name="submit" value="Login" /></td></tr> </table> </form> login2.php <?php $username = $_POST['username']; $password = $_POST['password']; $submit = $_POST['submit']; if($username&&$password) { $query = mysql_query("SELECT * FROM urbex_users"); //Code to login! while($row = mysql_fetch_assoc($query)) { $db_username = $row['username']; $db_password = $row['password']; $db_userid = $row['user_id']; } //Check to see if they match! if($username==$db_username&&$password==$db_password) { $_SESSION['urbex_username']=$db_username; $_SESSION['urbex_user_id']=$db_userid; echo "<p>You have successfully logged in! Welcome back ". $db_username .".</p>"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php\">"; } else echo "<p>Login details incorrect. Please <a href=\"login.php\">Login</a> again!</p>"; } else{ echo "<p>Login details incorrect. Please <a href=\"login.php\">Login</a> again!</p>"; } ?> I hope some one can help me with this, it totally has me stumpt!
  16. sorry my mistake. Putting it before the while loop! DOH
  17. thanks for your reply. That array didn't work in this instance. $status_result2 = array('PENDING','ACCEPTED','DECLINED'); echo $status_result2[$status_result]; while($row = mysql_fetch_assoc($query)) { $status_result = $row['status']; } currently the integer in status on database is 0.
  18. Hi how can I echo one variable that will check the integer from the database and print its associated text. if($status_result ==0){echo "<P>PENDING</p>";}; if($status_result ==1){echo "<p>ACCEPTED</p>";}; if($status_result ==2){echo "<p>DECLINED</p>";}; sorry bit of a php noob! thanks for nany help P.S I have a similar column in database but with only 2 possible options 0 or 1, so I used the ternary operator: $quote_result2 = $quote_result == 0?'<p>PENDING</p>':'<p>SENT</p>' . But not sure best way to did it with more than 2 options.
  19. Ive managed to come up with this: <html> <head> </head> <body> <form enctype="multipart/form-data" action="form.php" method="POST"> <input type="text" size="5" name="user" value="User" /><input type="text" size="5" name="level" value="Level" /><input type="text" size="5" name="skill" value="Skill" /><input type="submit" value="Send" height="2" /> </form> <hr /> <?php $myFile = "formdata.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); fwrite($fh, $_POST['user']); $stringData = " reached level "; fwrite($fh, $stringData); fwrite($fh, $_POST['level']); $stringData = " in "; fwrite($fh, $stringData); fwrite($fh, $_POST['skill']); $stringData = ".<br />"; fwrite($fh, $stringData); fclose($fh); ?> <?php $myFile = "formdata.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 10000); fclose($fh); echo $theData; ?> </body> </head> It seems to work well for what i need, but can anyone help me with getting the latest submissions at the top, instead of at the bottom?
  20. Ive tried the folowing code in the formdata.php file: <?php $myFile = "formdata.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); fwrite($fh, $_POST['user'],$_POST['level'],$_POST['skill']); fclose($fh); ?> I thought this would post the 3 bits of data in the form but im clearly missing something.
  21. Im trying to get to grips with what i need. So far: formdata.txt where the 3 bits of data will be stored. formdata.php where the php code to append the data to the formdata.txt file and the form markup, with an iframe underneath the form displaying the contents of the formdata.txt file. <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="text" size="5" name="user" value="User" /><input type="text" size="5" name="level" value="Level" /><input type="text" size="5" name="skill" value="Skill" /><input type="submit" value="Send" height="2" /> </form> <hr /> I have no idea where to start with the php code to apply the form data to the text file though . any help would be much appreciated.
  22. Heya I would love to be able to have something where by users can paste their current status to be viewed by other users. To be more specific I would like a user to be able to input his/her name, level achieved and in which skill. So other users can find it easier to find hunting groups.(mmorpg related ). Preferably the data could be saved in a text file. Perhaps an input feild at the top of the block would look somethingn like: Name: [input field] Level: [input field] Skill: [input field] Send (button) Monje reached level 230 in Melee. Yakapo reached level 250 in Offensive Affliction. Jenny reached level 64 in Desert Forage. This could perhaps be used to great effect in a more general way to quickly check the status of forums users. Any help on this would be much appreciated!
  23. Im just wondering if I might be able to add to the existing server status php code I have on my site. It simply shows different images (green for server open, amber for server lock, red for server closed). How might i add to the code to log the last time the server closed and could I use a counter from the point when the server status displays open? So it additionally have: Last reset: Jan 4th 2009 13:44 (When the server status last displayed the red "closed" image) Uptime: 24hrs 32m 14s (A counter running from when server status last displayed the green "open" image) <?php // retrieve information from Ryzom's website $server_data = file('[url=http://atys.ryzom.com/serverstatus/status.php]http://atys.ryzom.com/serverstatus/status.php[/url]'); for ($i = 0; $i < sizeof($server_data); $i ++) { $data = explode('|',$server_data[$i]); $server = $data[0]; $status = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_closed.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_closed.jpg]http://www.dcpryzom.co.uk/images/server_closed.jpg[/url]</a>" alt="Closed" />'; $server_img['Aniro'] = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_ani.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_ani.jpg]http://www.dcpryzom.co.uk/images/server_ani.jpg[/url]</a>" alt="Aniro"/>'; $server_img['Leanon'] = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_lea.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_lea.jpg]http://www.dcpryzom.co.uk/images/server_lea.jpg[/url]</a>" alt="Leanon"/>'; $server_img['Arispotle'] = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_ari.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_ari.jpg]http://www.dcpryzom.co.uk/images/server_ari.jpg[/url]</a>" alt="Arispotle"/>'; switch($data[1]) { case 1: $status = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_open.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_open.jpg]http://www.dcpryzom.co.uk/images/server_open.jpg[/url]</a>" alt="Open" />'; break; case 2: $status = '<img src="<a href="http://www.dcpryzom.co.uk/images/server_locked.jpg" target="_blank">[url=http://www.dcpryzom.co.uk/images/server_locked.jpg]http://www.dcpryzom.co.uk/images/server_locked.jpg[/url]</a>" alt="Locked" />'; break; } echo $server_img[$server] . $status .'<br />'; }?>
  24. Heya Ive found this php code that tracks server uptime and tried to apply the server id like to track, but it read 0 days 0 mins 0 secs, when i know the server has been up for a few days straight. The server ip address is ari1.ryzom.com. <?php $uptime = @exec('uptime'); preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime,$avgs); $uptime = explode(' up ', $uptime); $uptime = explode(',', $uptime[1]); if (strpos($uptime[0],"day")===false){ if (strpos($uptime[0],"min")===false){ $days = 0; list($hours, $minutes) = explode(':',trim($uptime[0])); } else{ $days = $hours = 0; $minutes = (int)$uptime[0]; } } else{ $days = (int)$uptime[0]; list($hours, $minutes) = explode(':',trim($uptime[1])); } $hours = (int)$hours; $minutes = (int)$minutes; $server = gethostbyaddr ($_SERVER['ari1.ryzom.com']); echo "Uptime" <b>$server</b>: $days days, $hours hours and $minutes minutes"; if ($_SERVER['HTTP_HOST']!="www.esoftpro.com"){ echo "<br /><br /><div style=\"font-size:8pt\">Provided by <a href=\"http://www.esoftpro.com\">esoftpro.com</a></div>"; } ?> Any help much appreciated
×
×
  • 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.