-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Everything posted by doddsey_65
-
thanks, that works. However when i use this to display the name for the 2 attachments i have on the test post: <?php foreach($row as $key => $value) { $title = $row[$key]['attachments']; } ?> echoing $title shows the name of both posts twice. example of the html output: <div> attachment1 attachment2 </div> <div> attachment1 attachment2 </div> when it should be: <div> attachment1 </div> <div> attachment2 </div>
-
i tried it but im getting the error "Unknown column 'p_pid' in 'from clause'"
-
printed query: SELECT p.*, u.u_username, u.u_posts, u.u_avatar, u.u_signature, u.u_avatar_cropped, group_concat(a.a_name, a.a_size, a.a_date_posted separator '<br />') attachments FROM asf_posts as p JOIN asf_users as u ON (u.u_username = p.p_poster) LEFT JOIN asf_post_attachments as a USING (asf_posts.p_pid) WHERE p.p_tid = '158' GROUP BY p.p_pid ORDER BY p.p_time_posted ASC
-
move input box at the end of a previous echo line?
doddsey_65 replied to sdowney1's topic in PHP Coding Help
this requires css not php. enclose your pagination and form in a div then set one section to float:left and the other to float:right. or set them both to display:inline-block; -
im trying to pull the information for a post which is to include 3 db tables(posts, users, attachments) Ive tried the following code: $query = $link->query("SELECT p.*, u.u_username, u.u_posts, u.u_avatar, u.u_signature, u.u_avatar_cropped, group_concat(a.a_name, a.a_size, a.a_date_posted separator '<br />') attachments FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."users as u ON (u.u_username = p.p_poster) LEFT JOIN ".TBL_PREFIX."post_attachments as a USING (".TBL_PREFIX."posts.p_pid) WHERE p.p_tid = '$tid' GROUP BY p.p_pid ORDER BY p.p_time_posted ASC")or die(print_link_error()); but that generates the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.p_pid) WHERE p.p_tid = '158' GROUP BY p.p_pid ORDER BY p.p_time_pos' at line 10" All i am trying to do is pull everything from posts, join users and select all attachments that belong to the post. Here is my database setup(shortened) asf_posts p_pid | p_name | p_poster 1 test doddsey65 asf_users u_uid | u_username 1 doddsey65 asf_attachments a_aid | a_pid | a_name 1 1 name can anyone help?
-
im no expert but ill give it a shot: $id8 = array(); $result8 = mysql_query("SELECT * FROM customers WHERE whosclient = 'Lansoft'"); while($row8 = mysql_fetch_array($result8)) { $id8[].=$row8['id']; } $result = mysql_query("SELECT * FROM timesheets WHERE status = 3 AND billable = 1 AND client = '".in_array($id8)."' ORDER BY date, starttime"); while($row = mysql_fetch_array($result)) { That what you were after?
-
ok im stuck again and need help. I have gotten rid of the attachment system(too many issues) on ASF and decided to replace it with my own. The problem is that the original new post form is sent to php via jQuery. Obv i cannot do this with files so the attachment section needs to be a seperate form. Now i have no issues with sending files to the folder and sending their name to the database but i need to send multiple. so far when the user selects a file it will add the name of it to a hidden input element and each one that is added to that element is seperated with | . then in the php i would use explode on this element to get an array of the file names. but this only helps when sending to the database and not when moving files. I also dont want a page refresh when uploading files. No other file upload systems out there will work because they upload the file as soon as you press submit, but then how do i add the post id to the attachments row in the database?
-
the missing table error has been fixed. Thanks for letting me know. Im not sure i know what you mean.
-
that would be the simplest way, but the attachments are added to the database before the post is(not my script and not the way i prefer) so i dont have a post id to go off until the post is submitted. But by then the attachment is already in the database.
-
The Times are achanging: Storing date/times with PHP
doddsey_65 replied to kreut's topic in PHP Coding Help
use strtotime strtotime('12/31/2011 7:52am') or $date = $month.'/'.$day.'/'.$year.'/'.$time; strtotime($date) -
i have it so people can attach files to their posts. So on the end of the post table i have a colum called p_attachments. it contains data like so: username1-_-image1.jpg|username2-_-image2.png| I also have an attachments table with data like so: a_id a_name a_size 1 image1 456123 2 image2 123456 so when i display the posts i want to display the name of the attachment, and its size aswell as the image if it is an image. <?php $attachment_list = explode('|', $row[$key]['p_attachments']); $a_list = ''; $amount = count($attachment_list); $a_name = array(); $size = array(); $ext = array(); $_a_name = array(); for($i=0; $i<$amount-1; $i++) { $ext[] = preg_split('|\.|', $attachment_list[$i]); $names[$i] = $ext[$i][0]; $q = "SELECT * FROM ".TBL_PREFIX."post_attachments WHERE a_name = '".$names[$i]."'<br />"; $a_query = $link->query("SELECT * FROM ".TBL_PREFIX."post_attachments WHERE a_name = '".$names[$i]."'") or die(print_link_error()); $result = $a_query->fetchAll(); $size[] = round(($result[$i]['a_size'] / 1024), 2); $_a_name[] = preg_split('||', $result[$i]['a_name']); if($ext[$i][1] == 'png' || $ext[$i][1] == 'jpg' || $ext[$i][1] == 'jpeg' || $ext[$i][1] == 'gif' || $ext[$i][1] == 'bmp') { if(preg_match('#\[attachment=(.*?)\]#si', $p_content)) { $bb[$i] = "#\[attachment=(.*?)\]#si"; $html[$i] = '<blockquote class="attachment"><a class="attachment" href="'.$config['asf_root'].'attachments/\\1"><img class="attachment" src="'.$config['asf_root'].'attachments/\\1" alt="\\1" title="Click For Full Image" /></a><span><strong>'.$_a_name[$i].'</strong></span><span><strong>Size: </strong>'.$size[$i].'kb</span></blockquote>'; } } ?> but the code isnt looping through all of the attachments on a post, it only displays data from the last attachment. Any ideas?
-
im setting up a php and jQuery pm system and have run into a problem. When a user clicks on a message in the left column the right column is supposed to be populated with the message contents, however the content stays the same whichever message is clicked. <?php $query = $link->query("SELECT * FROM ".TBL_PREFIX."messages WHERE m_sent_to = '$user_name'") or die(print_link_error()); $row = $query->fetchAll(); foreach($row as $key => $value) { $_message_list .= '<dl class="message_row" id="row-'.$row[$key]['m_mid'].'">'; $_message_list .= '<dd class="message_author">'.profile_link($row[$key]['m_author']).'</dd>'; $_message_list .= '<dd class="message_date">'.asf_date($row[$key]['m_date_sent'], 'short').'</dd>'; $_message_list .= '<dd class="message_checkbox"><input type="checkbox" id="checkbox-'.$row[$key]['m_mid'].'" /></dd>'; $_message_list .= '<dd class="message_subject">'.$row[$key]['m_subject'].'</dd>'; $_message_list .= '</dl>'; $template->message_content = $row[$key]['m_content']; } ?> and the jQuery <script type="text/javascript"> $j = jQuery.noConflict(); $j(document).ready(function(){ $j('dl.message_row').click(function(){ $j('li.message').html('<?php echo $this->message_content; ?>'); }); }); </script> The content display is always the content of the last message.
-
I am now taking feature requests so if you have any please let me know. I am going to start working on a PM system and maybe my own texteditor. Then after i fix a few small bugs in the main programming i will be moving on to the admin center and finally the install wizard. Then it will be a fully fledged beta release.
-
just to let you know ASF has now moved. You can now find it at http://www.asimpleforum.co.uk There have also been a few updates and new features added which you can find out about here Thanks
-
im working on a point system for my forum where points are awarded based on actions taken. $scores = array( 'login' => 1, 'editor' => 10 ); so if a user logs in then they will be awarded 1 point, if they edit their post then they get 10 points etc. So in my login process page i process the login then award the points that it is worth with $score['login']. Everything works fine. My problem is that this is a forum package like phpbb and mybb where people download the package and can install their own forum. So i want them to be able to add to the points list. For example the admin chooses to award 10 points for every post that is made. how would i go about implementing this? the points categories would be in the database but what happens in the post processing page when i add the post to the database? how would i know that the admin wants some points awarded? the database would look like so: id title points 1 post 10 but the title can change based on the admins choosing of words. I hope i explained this ok.
-
because the query that runs on the next page to get the content of the post checks the database for the post name that equals the get value in the url.
-
I am using seo friendly urls so when someone makes a post named "this is a post" the url will point to www.example.com/topic/this_is_a_post But when the user enters a character in their post name that means something in a url(? /) it obviously breaks. How can i make the urls safe from this without str_replace as i want to keep the characters.
-
Hi, im using colorbox(basically like lightbox) for some links on my site. When a user clicks the link it opens this lightbox. But if they type the link into the address bar manually it takes them to the actual page(which isnt formatted properly). Is there a way to open up the lightbox when they enter the address manually? or a work around?
-
uid is autoincrementing yes, i hadnt thought about it but this is a huge security issue. I could just add a cookie with an id of 2 and hope for the best, if not i could try with different ids. needs to be solved aswell then. anyway here is my code: login_process.php $session_length = $_POST['session_length']; // a value from the select options $session_length !== 'no' ? $_SESSION['remember_me'] = 'yes' : $_SESSION['remember_me'] = 'no'; init.php if($_SESSION['remember_me'] == 'yes' && !isset($_COOKIE['uid'])) { setcookie('uid', $_SESSION['uid'], time()+(((60*60)*24)*365)); } elseif($_SESSION['remember_me'] == 'no' && !isset($_COOKIE['uid'])) { setcookie('uid', $_SESSION['uid'], 0); } if (isset($_COOKIE['uid'])) { $user->setup($_COOKIE['uid']);
-
When a user logs in it sets a cookie with their user id and sets the time they choose(either a session cookie or a cookie lasting one year for users who wish to stay logged in). when they select to stay logged in forever and close the browser the next time they open it, it tells them they arent logged in. however when they go to a new page they appear to be logged in. What i dont understand is why they have to go to a new page for it to say they are logged in. Here is the code which runs everytime the site is load if (isset($_COOKIE['uid'])) { $user->setup($_COOKIE['uid']); } user setup basically selects their info from the database and sets their username and other info to variables. Anyone know a better way to do this?
-
display current username first from array
doddsey_65 replied to doddsey_65's topic in PHP Coding Help
thanks for the reply. Since my actual array contained info like array{ [0] => username1 [1] => date1 [2] => username2 [3] => date2 } i simply used this: if(in_array($user->user_name, $likes)) { $user_key = array_search($user->user_name, $likes); $date = $likes[$user_key+1]; $date_key = array_search($date, $likes); unset($likes[$user_key]); unset($likes[$date_key]); array_unshift($likes, $user->user_name, $date); } thanks for the help -
Example: i have an array of names array{ [0] => john [1] = ted [2] = jeff } and i display them like this: john, ted, jeff but jeff is currently logged in so i want his name to display first(i have my reasons lol) how would i go about this? i got as far as: if(in_array($user->user_name, $likes)) { $user_key = array_search($user->user_name, $likes); } then hit a brain freeze. Thanks
-
both good options. I solved it with this however: $key = array_search($user_name, $like_list); $date = $like_list[$key+1]; $date_key = array_search($date, $like_list); unset($like_list[$date_key]); unset($like_list[$key]); thanks for the replies
-
I have an array with content like so array{ [0] => username1 [1] => date1 [2] => username2 [3] = date2 } I want to select username2 and delete it so i do this: $key = array_search('username2', $array); unset($like_list[$key]); That works fine, but i also want to delete the next value after it. Any one know how i would do this? calling next on the array will just return $array[1] as $array[0] is the current key. Thanks