Jump to content

JonnySnip3r

Members
  • Posts

    87
  • Joined

  • Last visited

Everything posted by JonnySnip3r

  1. Hey guys im just starting to use Prepared Statements in php and i am trying to build a search but i have come across a problem. Hope someone can help or point me to more information on how to resolves this. Ok here is the code below:: public function search($string) { if(strlen($string) > 40) { return "Woow too many words, please shorten your search."; } if(empty($string)) { return "I'm a search, you type things in and I find. Please enter something and try again!"; } if(strlen($string) <= 3) { return "Come on dude, you expect me to find summin with that? Type some more tags in!"; } $x=0; // Teh string could be multiple searches so explode:: $string = explode(" ", $string); foreach($string as $search) { $x++; if($x == 1) { @$sql .= "(blog_tags LIKE '%$search%')"; } else { @$sql .= " OR (blog_tags LIKE '%$search%')"; } } $sql = "SELECT blog_tags FROM subarc_blog WHERE $sql LIMIT 40"; // TODO:: Count how many search results found:: $stmt = $this->conn->prepare($sql); $stmt->execute(); $stmt->bind_result($search); Ok by using the bind_result() i need to know how many result are being returned to add them to a variable is this correct ? if so how can i tell how many results have been returned ? hope this makes sense
  2. Thanks very much for the fast response dude will give it ago
  3. Hey guys im making a blog and when i make a post it automatically takes the date and created an archive based on what ever i have in the database (date wise) anyways it works almost fine but if i make a date in the same month it duplicates like so: October 2010 October 2010 November 2010 Is there away where i can limit October by 1 but when i come to make a post next year it will still display like so: October 2010 November 2010 December 2010 January 2011 ... October 2011 If i show you the code might make more sense haha:: public function create_archive() { // Loop through the database grabbing all the dates:: $sql = "SELECT blog_date FROM subarc_blog"; $stmt = $this->conn->prepare($sql); $stmt->execute(); $stmt->bind_result($date); $rows = array(); while($row = $stmt->fetch()) { $date = explode("-",$date); $month = date("F",mktime(0,0,0,$date['1'])); $year = $date[0]; $item = array( 'blog_month' => $month, 'blog_year' => $year ); $rows[] = $item; } $stmt->close(); return $rows; } and the sidebar looks like so:: <ul class="sidebar"> <?php $result = $Database->create_archive(); foreach($result as $row) : ?> <li><a href=""><?php echo $row['blog_month'] . " " . $row['blog_year']; ?></a></li> <?php endforeach; ?> </ul> Hope someone can help!
  4. I am currently building the application and havent configured anything like that yet but your right its silly haha just thought it would make it more urm better looking :S:S
  5. i have no idea haha just looks more umm i dunno haha i dont actually use jibber jabber jkljslks i use stuff like this:: ?0012=00xb1 oh dear haha
  6. Hey guys im fairly new to php i cant really keep using that as an excuse anyway im to the point where i am comfortable with procedural php style programming and i have moved on to object orientated and prepared statements etc. Anyways this has no relevance to that sorry. Ok when using $_GET in php say for example i wanted to log a user out i would use ?status=logout or whatever i have started to instead use that use codes like ?abihcofscj=21904jkq i know this looks weird and there is probs no need but does any over sites use this type of behavior or am i just being retarded haha thanks
  7. Hey guys i have been thinking how do i go about copyrighting my php application? if say i wanted to sell it on a script site such as codecanyon what can i do GPL? im foggy in this area no idea haha and what happens if someones uses a version they havnt paid for what actually can i do?? im just curious about this as im thinking of selling one i dont think there is much you can do and is there anypoint ?
  8. Thank you very much i will try them out now Thanks again!!
  9. Please are going to start hating me about this haha. Hey guys i have been trying to do this for a few hours and my brain is hurting haha hope someone can help. Ok here is what i am trying to do. I have been making a website that allows users to make friends below is my friends table:: NAME: member_friends id friend_id << Person who has been sent the friend request my_id << Person who sent the friend request friend_since << when did they become friends is_friend << is set to 0 then friend request pending and this is the member_topics message_id member_id << this stores the id of the member from the members table message_contents << stores their message message_date message_reported << if set to 1 the message has been reported Ok basically i want the messages to be displayed on the members home page if they are friends, so if my name is JamesDean and i befriended a person called Harry if i post a message i want harry to see this and any other friends i may have. Same goes for their messages. Sorry if im confusing you stay with me. Ok here is what i am trying to do (did i mention im fairly new to php so please if im doing something wrong dont hurt me (: ) $query = mysql_query("SELECT * FROM member_friends"); while($row = mysql_fetch_array($query)){ $friend_id = $row['friend_id']; // Ok this is where i want the while loop to loop through all of my friends // Ok set up the new filter im gunna get lost here now $sql = mysql_query("SELECT a.*,b.* FROM member_topics as a, member_friends as b WHERE (a.member_id = b.my_id OR a.member_id = b.my_id) AND ((b.friend_id = '$friend_id') AND b.my_id = '$my_id') ORDER BY a.message_id DESC"); // $my_id is a variable created from session so thats ok and the $friend_id i want that to change fromt he first loop so the statement changes for all of my friends. // Sorry for the query above i have tried that many i dont even know my gender anymore // So while loop in a while loop i think while($row = mysql_fetch_array($sql)){ $message_id = $row['message_id']; $member_id = $row['member_id']; $message_contents = $row['message_contents']; $message_date = $row['message_date']; $message_type = $row['message_type']; $message_reported = $row['message_reported]; } } something like this hope someone can point me in the right direction before my brain fails thanks in advanced!!!!!!!
  10. Thanks dude i have a member_id in each one because i can then relate what ever is in that table to the member. Thanks!!
  11. hey dude here is the problem:: $friend_query = mysql_query("SELECT * FROM member_friends WHERE my_id = '$my_id'"); while($row = mysql_fetch_array($friend_query)){ $friend_id = $row['friend_id']; $sql = mysql_query("SELECT a.*,b.* FROM member_topics as a, member_friends as b WHERE (a.member_id = b.my_id) AND ((b.friend_id = '$friend_id') AND b.my_id = '$my_id') ORDER BY a.message_id DESC"); while($row = mysql_fetch_array($sql)){ $message_id = $row['message_id']; $member_id = $row['member_id']; $message_contents = $row['message_contents']; $message_date = $row['message_date']; $message_type = $row['message_type']; $message_reported = $row['message_reported']; $mem_image = get_member_image_from_member_id($member_id); $member_name = get_member_name_from_member_id($member_id); // Clean:: $message_cleaned = bad_word_filter($message_contents,$my_id,$message_id); echo "<div id=\"message_section\">"; echo "<img src='profile/images/$mem_image' alt='Message Image' />"; echo "<h5><a href='http://mysite.com/$member_name'>$member_name</a> - $message_date</h5>"; echo "<p>$message_cleaned</p>"; echo "</div><!-- end message_section -->"; } } when i loop i dont think its passing the new value into the while loop hence the reason the query isnt working is this correct? or is there a easy way i always seem to do the long way haha Thanks!!!
  12. Hey guys i have a query that select from multiple tables and works fine however i have the same field name in each table called:: member_id but i want to select specifically the member_id from table1 do i need to change the name when i loop through them? i really dont want to do that but if it confuses php unless is there a way when doin a while loop i specify what table i want it from? while($row = mysql_fetch_array($query)){ $member_id = $row['member_id']; }
  13. ITS ALIIIIVEEE needed to tweak the query abit but thankyou very much!!!
  14. Hey guys i have been making a site that allows people to make friends and make posts on each walls a majority is done now but when i came to do the posting on walls i have hit one cause i cant figure out the query i will need for such a pretty complex task. It works like this i have a friends table and a topics table each something like this:: member_topics << Name topic_id member_id << have one of these in every table topic_title topic_date topic_content and in the friends one:: friends_table << name id member_id << id of the person who made the friend request friend_id << id of the person accepted the friend request is_friend << if 0 friend request pending all works nice as pic however i only want to show posts to those who are friends so if i go on my profile section i will see all my friends topics and they will see mine but i cant seem to fathem out the query i have tried many ways im confused i can get it to show mine no problem. any suggestions? hope someone can help Thanks!!
  15. Hey guys i have been making a website where friends can post on each others profiles like facebookish anyways im not sure if this is th ebest way to do it but i have this below its part of the code that pulls all the friends of the member from the database:: $query_friend = mysql_query("SELECT my_id,friend_id FROM site_friends WHERE my_id='$my_id'"); while($row = mysql_fetch_assoc($query_friend)){ $friend_id = $row['friend_id']; } then i pass it into a function blah blah not got that for yet anyway what happens if this person ends up having 100s of friends will this be harsh on the servers memory? or should i not worry to much ? hope someone can help thanks!!
  16. Hey guys i have been making a php gallery and i want to do the rest using jquery, when you click an album cover at the top of the page how can i have its contents loaded into a div below. Ok i loop through all the albums at the top of the page using php and they all display fine when you hover you see various information and when you upload an image its linked to what ever album you have chosen so if i choose say the first album it will be linked to all the images in that album (Sorry if im confusing you) SO anyways i have an id="" attached to each album, is there a way in jquery i can pass that id using $.ajax and return all the images in a div below? i have been looking high and low and cant find much on it. im fairly new to jquery but getting the hang of it i think. Hope someone can help point me in the right direction
  17. Hey guys does anyone know how i can configure MAMP PRO and postfix to send mail via php? i have tried loads of ways on the internet and cant get it to work :@ weirdly it was working and now decided to stop if its any help i am with googlemail and my ISP is TalkTalk (Uk) hope someone can help.
  18. Hey guys, i have been creating a profile page for a site i am doing. When i upload an image the profile image gets resized to 150px x 150px (CSS) however you can imagine if the image isnt a perfect size it will be squashed. Is there anyway i can resize the image? so that it doesnt look squashed like keep the full size upload image but pass it through a function before it displays in the profile section? if someone could point me in the right direction that would be awesome. Thanks!!
  19. Hey guys does anyone know how i would go about generating a random word from an array? For example: $words = array("[apple]","[banana]","[kiwi]"); how would i have php choose one of these words and then spit it out? Thanks!!!
  20. YEAH!!! thats perfect thanks guys :D woo
×
×
  • 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.