Jump to content

mykmallett

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Everything posted by mykmallett

  1. No? can nobody tell me what im doing wrong? Im returning the JSON into data and each array value is being outputted as an unordered list? What is wrong here?
  2. I cannot for the life of me figure out how to do anything with the JSON file that Facebook events give to me I have this AJAX: $.getJSON("getevent.php?event="+event,function(data) { var items = []; $.each(data, function(key, val) { items.push('<li id="' + key + '">' + val + '</li>'); }); $('<ul/>', { 'class': 'my-new-list', html: items.join('') }).appendTo('body'); } Which passes a Facebook events URL that the user enters to this PHP $url = $_GET['event']; parse_str( parse_url( $url, PHP_URL_QUERY ) ); $id = $eid; $url = 'https://graph.facebook.com/'.$id; $json = file_get_contents($url,0,null,null); $json_output = json_decode($json, true); echo $json Which would output json like this: { "id": "331218348435", "owner": { "name": "Julia Lam", "id": "2503747" }, "name": "Facebook Developer Garage Austin - SXSW Edition", "description": "Join the Facebook team and local developers for a deep dive into the latest and most exciting ways developers are building with Facebook technologies. \n\nCome to learn, stay to make friends!\n\nTentative Agenda:\n2:00 - 2:30 PM - Registration\n2:30 - 3:30 PM - Learn the latest from Facebook and local developers\n3:30 - 5:30 PM - Drink with friends! Stay and mingle with your developer community.\n\n*Come early! Drink tickets and t-shirts provided to the first 300 attendees. Cash bar provided for all attendees.\n\nTopics & Speakers:\n--Multi-Platform Social Games (Gareth Davis, Facebook) \n--Increasing Mobile Engagement with Facebook Connect (Josh Williams, Gowalla)\n--Facebook Integration with Seesmic (or How to Build Community Using Octopus Balls...) (John Yamasaki, Seesmic)\n--Going multi-platform: the brave new world beyond facebook.com (Sebastien de Halleux, Playfish / EA Interactive)\n--Socially Connected Exploding Gems Everywhere...Excellent! (Jon David, PopCap Games)\n\n* Emceed by Austin local: whurley, Chaotic Moon Studios\n* All are welcome to attend, no badge is required.\n* If you can't make it in person, you can join the live stream, beginning at 2:00 PM CST, here: http://ustream.tv/fbplatform \n\n***DAYLIGHT SAVINGS STARTS SUNDAY AT 2 AM, PLEASE ADJUST YOUR CLOCKS ACCORDINGLY***", "start_time": "2010-03-14T14:00:00", "end_time": "2010-03-14T17:30:00", "location": "The Phoenix", "venue": { "street": "409 Colorado St.", "city": "Austin", "state": "Texas", "country": "United States", "latitude": 30.2669, "longitude": -97.7428 }, "privacy": "OPEN", "updated_time": "2010-04-13T15:29:40+0000" } Its all working fine up until it is supposed to do something with the JSON. Firebug is saying it is recieving the JSON return fine. What I would like to eventually do with it is assign each part to a variable for later use, but I just cannot figure out what to do with it. Can anyone help, I have been reading conflicting tutorials and examples on ajax for days now. Thanks Mike
  3. Wow, fantastic! Thanks very much. Just so I'm clear, as I'm unfamiliar with this syntax, this: $linkName = ($linkID!=3) ? 'NULL' : mysql_real_escape_string(trim($_POST['link_name'])); Means if $linkID does not equal 3, then $linkName = 'NULL', else it equals the escaped value of $_POST['link_name'] Am I correct?
  4. Hi, I have a form that I want to allow users to be able to add specific links, some are set types (domains) and just require the iser to enter the link, however, one is for whatever they wish and they must enter a name to describe it. Now im going to enter it into a database with the following columns: USER_ID || LINK_URL || LINK_TYPE || LINK_NAME Link name is optional (only needed if the link type is their own custom one), the link types are ID's related to a table of link types (facebook, twitter etc). Now I'm assuming that to differentiate the form elements for insertion into the database I would need to have a hidden form element with the type ID inside? However I don't really know how to go on from here. A small version of the form would be <input type="text" name="facebook_link" /> <input type="hidden" name="facebook_id value="1" /> <input type="text" name="twitter_link" /> <input type="hidden" name="twitter_id value="2" /> <input type="text" name="own_site" /> <input type="text" name="own_site_description" /> <input type="hidden name="own_site_id" value="3" /> However, I'm assuming this is wrong because I'll need to enter everything into an array won't I? I just can't get my head round it to out put thi results into a foreach statement. Can anybody help me please?
  5. I saw something like that and wondered whether to go down that road. I wanted something that was slightly more intuitive tho, that links items via a description, rather than having to choose each item to link. After a few hundred products, doesn't that become a little overwhelming? Having to add each relevant item to the cross sell list? I imagine this is something that is very useful for selling , say batteries with a walkman...but not for finding things that are similiar based on your previous choices. I'm trying to imagine how Amazon build a list of recommendations, because, at least with music, it's very effective. I'm not slating your method by the way, these are genuine questions. I think I will do the cross selling method also for extra school boy points.
  6. I cant find anything that tells me how to search for multiple keywords in LIKE and how to sort by relevance, this is something I will investigate further when my original question has been commented on. My question is more 'is this a feasible method'. Im not asking for code, im just asking for help with my logic. There's no point me spending hours trying to slap together poor SQL statements if someone can point me to something more economical. Sadly, searching for 'recommended' followed by anything at all on here and on google is not very helpful.
  7. I dont see why that is? If its because of a primary key issue in the 2nd table, I would have the product_id and the meta_id as a clustered primary key, or just have a third auto-incrementing column. Or am i missing something? Can you elaborate please.
  8. Hi, I'm writing a PHP mySQL ecommerce website for a uni project. I'm having difficulty thinking of an effective and efficient way to do the "you may also be interested in" part. I was thinking of having a table of meta data like such meta_id | meta_keyword 1 | Gold 2 | Silver etc. Then having a second table that was filled in by admin when the product was put in the catalogue that was populated by choosing one of the meta keywords available (or adding one to the metadata table) product_id | meta_id 2 | 4 2 | 5 2 | 8 3 | 3 3 | 4 3 | 8 etc So basically when the product page was called it would see which meta keywords were associated with the product, then bring up a list of products with matching keywords. However, firstly im not sure if this is the right approach. And secondly, I'm not sure if there's a SELECT statement that would allow me to search the meta table well, or with any relevance. Am I on the right lines? Thanks in advance Mike
  9. I've echo'd the $query on a successful insertion (when I change a field) and on an unsuccessful one, where no fields have been changed and the query's are exactly the same. The variables are definitely set... EDIT: Sorry ive just realised why this is. Its because it is actually inserting the data, but because the data is exactly the same the num_effect_rows != 1 and so is triggering the error. I could take this out completely I guess and it wouldn't bring up a false error message. But is there a way of finding out if this was successful without num_affect_rows
  10. how do I echo mysql_num_rows? I can't seem to find a way that doesnt result in 'expects parameter 1 to be resource'?
  11. I have a edit-profile application that validates a form and then updates the records in the sql table. Like most standard apps like this it fetches the users details from the database and populates the form, then the user can change anything and submit. Now when the information is entered into the form it goes through the app ok. If you then go back onto this page and do not touch any of the fields it doesnt work. Basically it won't let you submit anything thats already in the table row. It's not getting through to the mysql part so its not an sql error, its a problem with the variables not being set: if (isset($_POST['submitted'])) { // Handle the form. require_once ('../mysql_connect.php'); // Connect to the database. // Check for a first name. if (preg_match('/^[[:alpha:]\.\' \-]{2,15}$/i', stripslashes(trim($_POST['first_name'])))) { $fn = escape_data($_POST['first_name']); } else { $fn = FALSE; echo '<p><font color="red" size="+1">Please enter your first name!</font></p>'; } // Check for a last name. if (preg_match('/^[[:alpha:]\.\' \-]{2,30}$/i', stripslashes(trim($_POST['last_name'])))) { $ln = escape_data($_POST['last_name']); } else { $ln = FALSE; echo '<p><font color="red" size="+1">Please enter your last name!</font></p>'; } // $t = escape_data($_POST['profiletype']); // Check for an email address. if (preg_match('/^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$/i', stripslashes(trim($_POST['email'])))) { $e = escape_data($_POST['email']); } else { $e = FALSE; echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>'; } // Check for a password and match against the confirmed password. if (preg_match('/^[[:alnum:]]{4,20}$/i', stripslashes(trim($_POST['password1'])))) { $p = escape_data($_POST['password1']); } else { $p = FALSE; echo '<p><font color="red" size="+1">Please enter a valid password!</font></p>'; } $ma = escape_data(htmlspecialchars($_POST['about'])); if (preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', ($_POST['website']))) { $website = escape_data($_POST['website']); $mw = "'$website'"; } else if (empty($_POST['website'])) { $mw = 'NULL'; } else { $mw = FALSE; echo '<p><font color="red" size="+1">Please enter a valid website URL, or clear the entry</font></p>'; } if ($fn && $ln && $e && $p && $ma && $mw) { // If everything's OK. // Query the database. $query = "SELECT username FROM users WHERE (username='$member' AND pass=SHA('$p'))"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (@mysql_num_rows($result) == 1) { // A match was made. // Update records $query = "UPDATE users SET email='$e', first_name='$fn', last_name='$ln', member_about='$ma', member_website=$mw WHERE username='$member'"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (mysql_affected_rows() == 1) { // If it ran OK. // Finish the page. echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; //include ('./includes/footer.html'); // Include the HTML footer. exit(); } else { // If it did not run OK. echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>'; } } else { // The password not matched. echo '<p><font color="red" size="+1">Your password is incorrect!</font></p>'; } } else { // If one of the data tests failed. echo '<p><font color="red" size="+1">Try Again ' . $member . $mw . '</font></p>'; } } The error coming up is the 'could not be registered' line, suggesting that the variables aren't setting correctly for some reason. Any help would be appreciated, thankyou
  12. I am currently building a website for djs to host mixes. I have coded the registration form and then had coded the registration to create a table in the database with the name media(followed by whatever the users user_id was). This table would then hold all the information for the mixes, each user would then obviously have one. Now it works perfectly...however, I just had a little crisis that tells me that maybe I shouldnt be giving the website the level of previliges to create a table. Maybe I should just have one table with all the mixes in (could get very large). Am I being paranoid? Which option do you guys recommend?
×
×
  • 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.