Jump to content

fife

Members
  • Posts

    381
  • Joined

  • Last visited

Everything posted by fife

  1. cool ok thank you
  2. fife

    Join Issues

    right I made those changes an I still get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sites/members/edit_member.php on line 239 How do I go about echoing the actual query?
  3. like so... echo" $query = mysql_query("SELECT * FROM table WHERE memberID = ".$User['memberID'].""); "; ??????????????
  4. fife

    Join Issues

    the table structure again...... FAVOURITES CATEGORY FavID, catID memberID, category favourite, order catID and favourite are the same. 1 User will have 5 entries in FAVOURITES and they will all be different.
  5. fife

    Join Issues

    Brill ok I have my error...... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sites/edit_member.php on line 239 It seems to be referring to... while($row1 = mysql_fetch_array($new_fav)) from $new_fav = mysql_query("SELECT favourites.*, club_category.* FROM favourites INNER JOIN club_category ON favourites.favourite = club_category.catID WHERE favourite.memberID = ".$User['memberID']." " or die(mysql_error())) ; while($row1 = mysql_fetch_array($new_fav)) { if ($row1['favourite']) echo " <li>{$row1['favourite']}</li> "; } It could also be referencing to the line above though
  6. fife

    Join Issues

    if I include that error checking again nothing appears other than a blank section but it also leaves the rest of the page blank too.
  7. fife

    Join Issues

    sorry that was a typo. It is there it says..... $new_fav = mysql_query("SELECT favourites.*, category.* FROM favourites INNER JOIN category ON favourites.favourite = category.catID WHERE favourite.memberID = ".$User['memberID']." "); while($row1 = mysql_fetch_array($new_fav)) { if ($row1['favourite']) echo " <li>{$row1['favourite']}</li> "; } I dont recieve any error. Just nothing appears.
  8. fife

    Join Issues

    Ok I made the changes to my database as suggested. It now has favourites table with the memberID, the "favourite" number (which is the same as the catID in the category table) and the order in which they chose that favourite...... FAVOURITES CATEGORY FavID, catID memberID, category favourite, order I created a new join but again it does not work $new_fav = mysql_query("SELECT favourites.*, category.* FROM favourites INNER JOIN ON favourites.favourite = category.catID WHERE favourite.memberID = ".$User['memberID']." "); while($row1 = mysql_fetch_array($new_fav)) { if ($row1['favourite']) echo " <li>{$row1['favourite']}</li> "; }
  9. fife

    Join Issues

    Ok I have a join issue I can not solve. First I will give the two table stucture members categorys memberID fav_1 catID fav_2 category fav_3 fav_4 fav_5 Now when the member select their top five favourites it saves the catID an not the name. When I come to echo the members favourite obviously it show the number. I've been trying to write an inner join I believe to make it echo the name instead but I keeps failing. can somebody please tell me where i have gone wrong in the code? <?php $query = mysql_query("SELECT club_category.*, members.* FROM club_category INNER JOIN members ON club_category.catID = members.fav_1 WHERE memberID= ".$User['memberID']." "); $result = mysql_fetch_array($query); if ($User['fav_1']!="") { if($result['fav_1']) {echo " <li>{$result['categorys']}</li> ";}} if ($User['fav_2']!="") {if ($User['fav_2']){echo " <li>{$result['categorys']}</li> ";}} ?> It just seems to be showing the result of fav_1 two times on the screen.
  10. is it just me or has the mark as solved button disappeared? This issue was solved
  11. I have this awesome little script that I have to configure. My php is limited but I can get by, my javascripting is very limited to say the least but I can see whats wrong with the script. ok first I will post some of the orginal javascript and the query that it runs..... <script type="text/javascript"> // <![CDATA[ $(document).ready(function(){ $('#shareButton').click(function(){ var a = $("#watermark").val(); if(a != "What's on your mind?") { $.post("posts.php?value="+a, { }, function(response){ $('#posting').prepend($(response).fadeIn('slow')); $("#watermark").val("What's on your mind?"); }); } }); next the form itself...... <form action="" method="post" name="postsForm"> <div class="UIComposer_Box"> <span class="w"> <textarea class="input" id="watermark" name="watermark" style="height:20px" cols="60"></textarea> </span> <br clear="all" /> <div align="left" style="height:30px; padding:10px 5px;"> </span> <a id="shareButton" style="float:left" class="smallbutton Detail"> Share</a> </div> </div> </form> now the php which is in an external sheet called posts.php ......... <?php include('dbcon.php'); function checkValues($value) { $value = trim($value); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $value = strtr($value,array_flip(get_html_translation_table(HTML_ENTITIES))); $value = strip_tags($value); $value = mysql_real_escape_string($value); $value = htmlspecialchars ($value); return $value; } function clickable_link($text = '') { $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); $ret = ' ' . $text; $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret); $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); $ret = substr($ret, 1); return $ret; } $next_records = 10; $show_more_button = 0; if(checkValues($_REQUEST['value'])) { $userip = $_SERVER['REMOTE_ADDR']; echo "INSERT INTO facebook_posts (post,f_name,userip,date_created) VALUES('".checkValues($_REQUEST['value'])."','".danny."','".$userip."','".strtotime(date("Y-m-d H:i:s"))."')"; mysql_query("INSERT INTO facebook_posts (post,f_name,userip,date_created) VALUES('".checkValues($_REQUEST['value'])."','".danny."','".$userip."','".strtotime(date("Y-m-d H:i:s"))."')"); $result = mysql_query("SELECT *, UNIX_TIMESTAMP() - date_created AS TimeSpent FROM facebook_posts order by p_id desc limit 1"); } //etc In the php section in the values there is this "danny" for the f_name The issue is simple. Instead of danny i want $User['memberID']. The problem I have is I dont know how to add the row to the javascript at the beginning to make it work. The best I have is this...... <script type="text/javascript"> // <![CDATA[ $(document).ready(function(){ $('#shareButton').click(function(){ var a = $("#watermark").val(); var b = $("<?php echo $User['memberID']; ?>").val(); if(a != "What's on your mind?") { $.post("posts.php?value="+a+"&mem="+b, { }, function(response){ $('#posting').prepend($(response).fadeIn('slow')); $("#watermark").val("What's on your mind?"); }); } }); //etc but this is not working. I would really appreciate some help on this as im all out of ideas. I would love this feature or one similar to work within my site. Thank you
  12. cool guys cheers
  13. Hi I have this code and when I echo the count it shows 1 when theres actually 5. Have I wrote it wrong $loginsq = mysql_query("SELECT email FROM logindetails WHERE email = ".$_SESSION['MM_Username'].""); $logins = mysql_fetch_array($loginsq); $logs = count($logins); echo $logs;
  14. can somebody please tel me how to make sure a field is a number? I have some error checking like if(empty($postcode)) { $errors[] = "Please enter your postcode"; } if(strlen($tel)<11) { $errors[] = "Please enter a phone number that is the correct length"; } But I dont know and cant find how to check for a number only.
  15. Im trying to echo certain code if the array returned is empty. I know for certain the array is empty and it works when its not empty. here is my code <?php while ($club = mysql_fetch_assoc($qclubs)) { if (empty($club)) {echo "<option value='None'>None</option>";} else{ echo" <option value='{$club['groupID']}'>{$club['group']}</option>"; }}?> Can someone please point out the error of my ways?
  16. fife

    Inner join issue

    Ok I tried what was posted but I still recieve an error. Ill give some more info now. Here is 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 '`club_category` ON `clubs.cat` = `club_category.catID` WHERE `cat` IN('0',' at line 1" here is the query I wrote.... <?php $Adds = sprintf("SELECT `clubID`, `name`, `cat`, `area`, `county`, `thumbsup`, `thumbsdown`, `logo`, `members` FROM `clubs` INNERJOIN `club_category` ON `clubs.cat` = `club_category.catID` WHERE `cat` IN('%s', '%s', '%s', '%s', '%s') AND `area` = '%s' OR `county` = '%s' ORDER BY rand() LIMIT 6", $User['fav_1'],$User['fav_2'],$User['fav_3'],$User['fav_4'],$User['fav_5'], $User['area'], $User['county']); $adverts = mysql_query($Adds) or die(mysql_error()); while($club_adds = mysql_fetch_assoc($adverts)){ echo {$club_adds['name']}{$club_adds['category']} } ?> the table structures CLUBS CLUB_CATEGORY name, catID cat, categorys in the clubs table the 'cat' is = to catID in the category table. I don't understand what the error saying but i think it is because I'm not saying the I need to select the two fields from the club_category table..... ie $Adds = sprintf("SELECT `clubID`, `name`, `cat`, `area`, `county`, `thumbsup`, `thumbsdown`, `logo`, `members`, `club_category.catID`, `club_category.categorys` FROM `clubs` INNERJOIN `club_category` ON `clubs.cat` = `club_category.catID` WHERE `cat` IN('%s', '%s', '%s', '%s', '%s') AND `area` = '%s' OR `county` = '%s' ORDER BY rand() LIMIT 6", $User['fav_1'],$User['fav_2'],$User['fav_3'],$User['fav_4'],$User['fav_5'], $User['area'], $User['county']); $adverts = mysql_query($Adds) or die(mysql_error()); while($club_adds = mysql_fetch_assoc($adverts)){ echo {$club_adds['name']}{$club_adds['category']} } ?> Obviously I cant put these two fields in this bit because its an sprintf statement and I'm not dynamically creating these two fields I'm just pulling them from the database. Am I right or completely way of the mark? If I am is there a way around this?
  17. Hi. I have a query which I wrote wrongly and then kenrbnsn came along and fixed it for me. I works great but I have realized that it needs an inner join put into it. If the query was written differently I could probably do it but its confusing me on how. I basically need an inner join on cat to my categorys table as at the moment the 'cat' is just coming up as a number and I want the word. Can someone please explain if this is possible and how to do it as I've spent about 5 hours going over and over it and its driving me crazy!!!!!!! $Adds = sprintf("SELECT `name`, `cat`, `area`, `county`, `thumbsup`, `thumbsdown`, `logo`, `cat`, `members` FROM `clubs` WHERE `cat` IN('%s', '%s', '%s', '%s', '%s') AND `area` = '%s' OR `county` = '%s' ORDER BY rand() LIMIT 6", $User['fav_1'],$User['fav_2'],$User['fav_3'],$User['fav_4'],$User['fav_5'], $User['area'], $User['county']); $adverts = mysql_query($Adds) or die(mysql_error()); while($club_adds = mysql_fetch_assoc($adverts)){ echo {$club_adds['name']} {$club_adds['cat']} } ?>
  18. fife

    echo IF

    brill thank you very much
  19. put or die (mysql_error()); here mysql_query($query) or die (mysql_error());
  20. fife

    echo IF

    I want to echo this div below but only if there is more than one of these fields missing. How would I go about this? <?php //only echo all of this if one or more of these fields does not exists so....... if () { echo" <div id=\"items_todo\"> <h3>Members Info</h3><br/> <ul>"; if (empty($User['address_L1'])) { echo "<li><a href=\"#\">Update Address</a></li>";} elseif (empty($User['intro'])) {echo "<li><a href=\"#\">About You</a></li>";} elseif (empty($User['profile_image'])){echo "<li><a href=\"#\">Add Profile Image</a></li>";} elseif (empty($User['Nickname'])){echo "<li><a href=\"#\">Add A Nickname</a></li>";} echo"</ul> </div>"; } ?>
  21. I dont think putting the users ID into the form is a good idea and make sure you run the code through $course = mysql_real_escape_string(trim($_POST['coursenametext'])); before you enter it into the database.
  22. ah sorry I see use your query to get the id and store it in a variable first then on update $query = mysql_query("UPDATE `courses` SET courseName = ".$_POST['coursenametext']." WHERE` ID` = '$id' ");
  23. try and pull the users ID from the database before you begin if(isset($_POST['Submit'])) { As i dont see where it is getting the ID from.
  24. I have just a general question about a friends system here with regards to the database design....... lets say you have a website where users can rent books. The database design would be MEMBER BOOK LINk memberid isbn memberid name name isbn Or something to that extent Now with a friends system like facebook has that "LINK" table would be absolutley huge and I cant see it being good design practise. I mean how do you suppose facebook does this. Do they have ...... FRIENDS myID friendID and just millions upon millions of repeated data? The only way I can see would be in the member table have a field called friends and then the ID's of each friend like so Friends 001, 002, 003, 004, 005, 006, 007, Now is my logic correct here or am I thinking of this totally the wrong way? Would the other way be a better option or would it take the system too long to get to the 1000,000 th record in the database? I believe the first option would be correct but I cant see how the server would handle the request if say you had 1000,000 users. It just seems to me that you would create too many records. In my website people can sign up to mulitple events but if every user had 100 events the link table would just be massive!!!!!!!!!!!!!!!!!!!!!! Im just after peoples input really on the situation. Thank you
  25. fife

    if statement

    maq is that debug code. I have never used any can you show me where to put it please?
×
×
  • 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.