Jump to content

hdshngout

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hdshngout's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello. Recently, I have been working on an advanced group feature for a website I contribute to. In order for this feature to work correctly, this immense number of tables were required. My problem arises when I create a query to delete a group. I used to just query each table one by one until the record was erased, however this proved to be somewhat heavy on resources. As per the suggestion of a co-developer and a bit of reading at the mysql manual, I discovered in theory, I could combine the "would-be" seven queries into one. Upon reading, I believe it can be done via a pseudo-join for lack of a better word. I attempted using a resource from another thread (http://www.phpfreaks.com/forums/index.php/topic,101350.0.html) and the query sort-of worked. However, it would only delete from `groups` nothing else. Below is a watered down example of the database structure and my "attempted" delete query. I am aware its complex and I don't want to make it seem like I'm trying to get someone else to do my work for me, its just I am rather stuck. Any help would be greatly appreciated. As per (http://www.phpfreaks.com/forums/index.php/topic,101350.0.html), I attempted to modify the answer he or she received. Below is the mess which resulted DELETE groups, groups_calendar, groups_memberships, groups_message_boards, groups_message_boards_posts, groups_message_boards_threads, groups_pages, groups_styles FROM groups LEFT JOIN groups_calendar ON groups.id=groups_calendar.group_id LEFT JOIN groups_memberships ON groups_calendar.group_id=groups_memberships.group_id LEFT JOIN groups_message_boards ON groups_memberships.group_id = groups_message_boards.group_id LEFT JOIN groups_message_boards_posts ON groups_message_boards.group_id=groups_message_boards_posts.group_id LEFT JOIN groups_message_boards_threads ON groups_message_boards_posts.group_id=groups_message_boards_threads.group_id LEFT JOIN groups_pages ON groups_message_boards_threads.group_id=groups_pages.group_id LEFT JOIN groups_styles ON groups_pages.group_id=groups_styles.group_id WHERE groups.id = ? --------------------Other Information------------------------- MySQL Version 5.0 What's happening: Only deleting the information from `groups,` nothing else. What should happen: All information linked with the `group_id` being deleted should be erased. What I've Tried: I've tried to write the query multiple times, using the examples from mysql.com, and other threads on this forum. --------------------------------------------------------------- I apologize for this post ending up as long as it did. and thank you for your time in reading my post. -Nick
  2. basically, what I am doing is letting users create "widgets" which can be used on other parts of the site. In keeping with the standard set out by other sites, the coding for these widgets are done in basic xhtml format. For example, if a "widget" were to contain <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head profile="http://www.netvibes.com/api/0.3/profile"> <title>Hello world</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <p>Hello world !</p> </body> </html> The information I would need from this widget would be between, <title></title> and <body></body> I have been able to "parse" the text between <title></title>, but I have not been successful with. I don't know how to get the code from between the <body> and </body> out. My test code, if anyone needs it is <?php $address = $_GET['address']; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $address); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); $content2 = htmlentities($file_contents); $content = $content2; echo $content; preg_match('/<title>(.*)<\/title>/', $content, $title_match); preg_match('/<body>(.*)<\/body>/', $content, $file_match); ?> <table> <tr><td><strong><?php echo $title_match[1]; ?></strong></td></tr> <tr><td><?php echo $file_data[1]; ?></td></tr> </table> I know its not secure, but I am just attempting to get a basic handle on getting what I need from the file.
  3. I have been working on basic parser for xhtml, but I have run into a problem, I used curl to get the page and was able to retrieve the title, but I have, from there, run into a snag. After doing some research, I discovered, the code I was using to get the data could not read new lines (\n), and I can't very well parse without the new lines. I need help parsing between <body> and </body> the code I am using is //Parser preg_match('/<body>(.*)<\/body>/', $content, $file_match); print_r($file_match); (its not reading at all right now.) If anyone could help me, I would greatly appreciate it! -Nick
  4. I generally use <script type="text/javascript" language="javascript"> function smilie(smilecode) { document.FORM_NAME.TEXTAREA_NAME.value += smilecode; } </script> Then to call on them, make a link like <a href="#" onclick="smilie(' ')"><img src="URL/TO/IMAGE" alt="" /></a> Hopefully thats not too messy
  5. For a site I am working on, I allow users to enter a simple code to pull their pictures from flickr. On the profile part however, I am running into a bit of trouble. The flickr results appear correctly, just in the wrong spot. In order to accomplish this, I have used preg_replace alongside preg_match. In short, I am trying to read the bit of code and replace it with the correct photos. I can not figure out how to control where the results appear. Any help would be greatly appreciated. (And a bit more information, I am using PHP 5 Flickr API phpFlickr ) The bit of code I believe the trouble is with are $sql_flickr = mysql_query("SELECT * FROM exterior_services WHERE owner='$userid' AND service='flickr'") or die(mysql_error()); $flickr = mysql_fetch_array($sql_flickr); $flickr_username = $flickr[username]; $flickr_num = $flickr_match[1]; $flickr_new_row = $flickr_match[2]; if(strstr($custom_coding, '<widget>$flickr_display') == TRUE) { //$custom_coding = preg_replace('/<widget>\$flickr_display\((\d+),(\d+)\)<\/widget>/',include('profile_stuff/flickr.php'),$custom_coding); $custom_coding = preg_replace('/<widget>\$flickr_display\((\d+),(\d+)\)<\/widget>/','',$custom_coding); include('profile_stuff/flickr.php'); } and then the phpFlickr part <?php define('secure','true'); require_once("services/flickr/phpFlickr.php"); // Create new phpFlickr object $f = new phpFlickr($api_key); $f->enableCache( "db", "mysql://$db_user:$db_pass@$db_pass/$db_name" ); $i = 0; // Find the NSID of the username inputted via the form $person = $f->people_findByUsername($flickr_username); // Get the friendly URL of the user's photos $photos_url = $f->urls_getUserPhotos($person['id']); // Get the user's first 36 public photos $photos = $f->people_getPublicPhotos($person['id'], NULL, $flickr_num); // Loop through the photos and output the html foreach ($photos['photo'] as $photo) { echo "<a href=$photos_url$photo[id]>"; echo "<img border='0' alt='$photo[title]' ". "src=" . $f->buildPhotoURL($photo, "Square") . ">"; echo "</a>"; $i++; // If it reaches the sixth photo, insert a line break if ($i % $flickr_new_row == 0) { echo "<br>\n"; } } ?> Once again, I greatly appreciate all help given. -Nick
  6. basically, what the script does is take the total number of points you have (earned from posting and other things around the site), and subtract the price of creating a user shop (cheesy I know).  This feature specifically is meant to subtact X amount from your total points depending on the size shop you wish to create. The problem is, the subtraction isn't initiating and I can't figure out why!  :P
  7. Ok, im working on a new site and I'm working on another feature. What its meant to do is from a set of radio buttons, you choose somthing and it subtracts X amount from your points depending on the choice. Sounds easy, right? Well of course when I mess with it, it won't work. Anyone see and problems that would cause it not to subtract? [code]<?php if (isset($_POST['submit'])) { function cleanUp($input) {   return htmlspecialchars(strip_tags(stripslashes(trim($input)))); } $shop_title = cleanUp($_POST['shop_name']); $shop_front = $_POST['shop_front']; $shop_front = str_replace("<", "[", $shop_front); $shop_front = str_replace(">", "]", $shop_front); $shop_desc = cleanUp($_POST['shop_desc']); $shop_desc = nl2br($shop_desc); $shop_size = cleanUp($_POST['shop_size']); $shop_location = cleanUP($_POST['shop_location']); $timestamp = strtotime("now"); $username = $logged['username']; if ( (empty($shop_title)) || (empty($shop_desc)) || (empty($shop_size)) || (empty($shop_location))) { include($_SERVER['DOCUMENT_ROOT']."/connect.php"); $sql2 = "SELECT * FROM shops WHERE owner = '$logged[username]'"; $result2 = mysql_query($sql2) or print ("Can't select table.<p>" . mysql_query()); $number = mysql_num_rows($result2); if ($number != 1) { include("../connect.php"); $sql = "INSERT INTO shops (timestamp, owner, shop_name, shop_desc, shop_front, shop_size, Shop_location) VALUES ('$timestamp','$username','$shop_title','$shop_desc','$shop_front','$shop_ size','$shop_location')"; $result = mysql_query( $sql ) or print ( mysql_error()); $id = mysql_insert_id(); $shop_size2 = $_POST['shop_size']; if ($shop_size2 == "4") { $price = "50"; } else if ($shop_size2 == "8") { $price = "100"; } else if ($shop_size2 == "12") { $price = "200"; } else if ($shop_size2 == "16") { $price = "300"; } else if ($shop_size2 == "20") { $price = "400"; } else if ($shop_size2 == "60") { $price = "600"; } include($_SERVER['DOCUMENT_ROOT']."/connect.php"); $sql4 = "SELECT * FROM users WHERE username = '$logged[username]'"; $result4 = mysql_query($sql4) or print ("Can't select table.<p>" . mysql_query()); while($row4 = mysql_fetch_array($result4)) { $points = $row4['points']; } $equation = ($points - $price); include("../connect.php"); $sql5 = "UPDATE users SET points='$equation' WHERE username='$logged[username]' LIMIT 1"; $result5 = mysql_query($sql5) or print (mysql_error()); if ($result5 != false) { echo "<span style=\"color: green;\">Success!  Your shop has been successfully created!It is located at <p><a href=\"shop.php?id=$id\">$address/shop.php?id=$id</a></span>"; } } else { echo "<span style=\"color: red;\">You Have already created a shop!</span>"; } } else { echo "<span style=\"color: red;\">You must fill in all the required fields.</span>"; } } ?>[/code] (by the way, I'm sorry if I accidentally broke any of the rules, still new here and learning my way around)
×
×
  • 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.