Jump to content

TCombs

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by TCombs

  1. Yes, Thank you!! That fixed it! Thanks again!!!
  2. Thanks for your response. Here is the upload function from the functions.php file function ProcessImageUpload($field, $image_destination) { //Your Image $imgSrc = $_FILES[$field]['tmp_name']; $imgName = $_FILES[$field]['name']; //getting the image dimensions list($width, $height) = getimagesize($imgSrc); //save original image move_uploaded_file($imgSrc, $image_destination . $imgName); }
  3. I had help last year creating a very basic store that simply shows products, an image for the product, price, etc. No financial information is being input on the site. The admin of the site can go in and add new products, along with their image. The site worked fine for the last year, now suddenly, they can't upload images. When an admin tried to upload an image for a product, this is the error I'm getting: 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 'image = ', B6405 Thumb.jpg' WHERE id = '64'' at line 1 When I look at the console in Firefox when executing the upload command, this is what I see: <br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/content/93/7468893/html/adminprodupdate.php</b> on line <b>73</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/content/93/7468893/html/adminprodupdate.php:73) in <b>/home/content/93/7468893/html/adminprodupdate.php</b> on line <b>82</b><br /> This is the code for the adminprodupdate.php file referenced above, Can someone please take a look at the code and let me know if they see anything obvious? <?php include("config.php"); include("db.php"); include("functions.php"); $id=$_POST['id']; $active=$_POST['active']; $cat_id=$_POST['cat_id']; $name=$_POST['name']; $description=$_POST['description']; $details=$_POST['details']; $price7=$_POST['price7']; $price=$_POST['price']; $price2=$_POST['price2']; $price3=$_POST['price3']; $price4=$_POST['price4']; $price5=$_POST['price5']; $price6=$_POST['price6']; $minimum=$_POST['minimum']; $arrsizes = $_POST['size']; $arrcolors = $_POST['color']; $image1=$_POST['image']; $image2=$_POST['image2']; $image_directory = $_SERVER['DOCUMENT_ROOT'] . '/store-images/'; $image1 = false; $image2 = false; if (is_uploaded_file($_FILES['image']['tmp_name'])) { ProcessImageUpload('image', $image_directory); $image1_name = $_FILES['image']['name']; $image1 = true; } if (is_uploaded_file($_FILES['image2']['tmp_name'])) { ProcessImageUpload('image2', $image_directory); $image2_name = $_FILES['image2']['name']; $image2 = true; } $sql="UPDATE products SET active = '$active', cat_id = '$cat_id', name = '$name', description = '$description', details = '$details', price7 = '$price7', price = '$price', price2 = '$price2', price3 = '$price3', price4 = '$price4', price5 = '$price5', price6 = '$price6', minimum = '$minimum'"; if ($image1) { $sql .= "image = ', $image1_name'"; } if ($image2) { $sql .= "image2 = ', $image2_name'"; } $sql .= " WHERE id = '$id'"; mysql_query($sql) or die ("Error: ".mysql_error()); $result = mysql_query("SELECT id FROM products ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $productid = $row['$id']; } mysql_query("DELETE FROM productoptions WHERE productid='$id'"); foreach ($arrsizes as $sizevalue) { foreach ($arrcolors as $colorvalue) { $sql2 = "INSERT INTO productoptions (productid, sizeid, colorid) VALUES ('$id', '$sizevalue', '$colorvalue')"; mysql_query($sql2) or die("Error: ".mysql_error()); } } header("Location: " . $config_basedir . "adminhome.php"); ?> Thank you in advance! If I didn't explain thoroughly, please let me know.
  4. I used custom fields for a series of real estate listing posts on a wordpress site. I want to query all posts by the State they are listed in and sort them alphabetically. (custom field: property_locations_state) Then I want to list the properties within that state. (custom field: property_name) For example: Indiana property 1 property 2 Michigan proptery 1 property 2 With the code below, I can see the posts by print_r($propposts), however, no results are being displayed. Please let me know if you can see what's wrong with this code. <?php $args = array( 'posts_per_page' => -1, 'meta_key' => 'property_locations_state', 'meta_query' => array( array( 'key' => 'property_locations_state' ), array( 'key' => 'property_name' )) ); $propposts = get_posts($args); //custom function for comparing the data we want to sort by function cmp($a, $b){ if ($a->property_locations_state == $b->property_locations_state) { return 0; } return ($a->property_locations_state > $b->property_locations_state) ? 1 : -1; } usort($propposts, 'cmp'); $directory = array(); foreach ($propposts as $proppost ) { // get all the posts data $posttitle = get_post_meta($proppost->post_id); if($posttitle){ foreach ($posttitle->property_locations_state as $title) { $directory[$title][] = array ( 'property_name' => $posttitle->property_name ); } } ksort($directory); // sort by state echo '<ul id="example1" class="accordion">'; foreach ($directory as $state => $lists) { echo '<li><h3>' .$state. '</h3>'; echo '<div class="panel loading">'; sort($lists); // sort Properties by name foreach ($lists as $list) { echo '<div id="membox">'; echo $list['property_name'].'<br />'; } echo '</div></li>'; } echo '</ul>'; } ?>
  5. Thank you so much! I spent almost all day yesterday trying to figure this out. You're a life saver :-)
  6. Thank you sir! Looks very good now! 1 last tweak, if a user has multiple instruments listed, can we get all instruments to show in the member output. For example, if you look at this link: http://afm1.org/wp/?page_id=677 You see that david abbott is listed under Accordian & Acoustic...which is CORRECT. however, under his email address only the 1 instrument is listed. Can we get both instruments listed here?
  7. @gizmoloa - Thanks for your response, not sure how the 'b' became 'B' when I pasted the code. I have noticed this editor is a little buggy. @barand - Thank you as well. The code you showed me got me a lot closer to what I need. however, it is listing each instrument with the same user. Here's what I have now: <?php $args = array( 'fields' => 'all', 'role' => 'Subscriber', 'meta_query' => array( array( 'key'=>'instrument' )) ); $members = get_users($args); //custom function for comparing the data we want to sort by function cmp($a, $B){ if ($a->instrument == $b->instrument) { return 0; } return ($a->instrument > $b->instrument) ? 1 : -1; } usort($members, 'cmp'); $directory = array(); foreach ($members as $member ) { // get all the user's data $member_info = get_userdata($member->ID); foreach ($member_info->instrument as $inst) { $directory[$inst][] = array ( 'lastname' => $member_info->last_name, 'firstname' => $member_info->first_name, 'address' => $member_info->address_1, 'city' => $member_info->city, 'state' => $member_info->state, 'zip' => $member_info->zip, 'phone' => $member_info->phone, 'email' => $member_info->email ); }} ksort($directory); // sort by instrument foreach ($directory as $instrument => $players) { echo '<h1>' .$instrument. '</h1>'; sort($players); // sort players by lastname foreach ($players as $player) { // output player details here echo '<div id="membox">'; echo $member_info->first_name. ' ' .$member_info->last_name.'<br />'; echo $member_info->address_1.'<br />'; echo $member_info->city.', '.$member_info->state.', '.$member_info->zip.'<br />'; echo $member_info->phone.'<br />'; echo '<a href="mailto:'.$member_info->email.'">'.$member_info->email.'</a><br />'; foreach ($member_info->instrument as $inst) { echo '<b>'.$inst.'</b>, '; } echo '</div>'; }} ?>
  8. Hello all! I've posted here in the past and had great success, hoping for the same today. I have a wordpress site and I'm trying to pull the members into a page and sort them by results. It's a Musicians site and I need to be able to sort the members by the instruments they play. This code will pull the members into the page and you can see the results at: http://afm1.org/wp/?page_id=677 <?php $args = array( 'fields' => 'all', 'role' => 'Subscriber', 'meta_query' => array( array( 'key'=>'instrument' )) ); $members = get_users($args); //custom function for comparing the data we want to sort by function cmp($a, $B){ if ($a->instrument == $b->instrument) { return 0; } return ($a->instrument > $b->instrument) ? 1 : -1; } usort($members, 'cmp'); foreach ($members as $member ) { // get all the user's data $member_info = get_userdata($member->ID); echo '<div id="membox">'; echo $member_info->first_name. ' ' .$member_info->last_name.'<br />'; echo $member_info->address_1.'<br />'; echo $member_info->city.', '.$member_info->state.', '.$member_info->zip.'<br />'; echo $member_info->phone.'<br />'; echo '<a href="mailto:'.$member_info->email.'">'.$member_info->email.'</a><br />'; foreach ($member_info->instrument as $inst) { echo '<b>'.$inst.'</b>, '; } echo '</div>'; } ?> What I want to do is have the Instrument as a title and have all of the members that play that instrument listed like this: <h1>Accordian</h1> Arpi Anderson 1234 Whitfield Avenue Cincinnati, OH, 45220 513-111-1111 arpianderson@hotmail.com Accordion, David Abbott 123 N. Ft. Thomas Ave. Ft. Thomas, KY, 41075 859-111-1111 davejanet@acninc.net Accordion, Acoustic, <h1>Violin</h1> Ann Baer 123 Cabinridge Batavia, OH, 45103 513-111-1111 violin@cinci.rr.com Violin, Any help would be GREATLY appreciated! Thanks
  9. Yeah, it's a Volusion template that I had to modify. It's a wreck, and if you try to validate it your browser may crash..lol I've just been trying to get by with it until I can setup a test environment, recreate the store the right way and upload it to the server. If I could get the product, price, link & image that would be great. But at this point I'd settle on just the image and link. The table structure in Volusion is horrible. There's the main content table, then within the backend of the store is where all of the WYSIWYG editors are for each product, article, page, etc. which automatically places items on the page depending on which box you check or uncheck. I hate it actually.
  10. Silk....this is the exact type of answer I was looking for. You gave me an option and explained why it was the right way to go. Its just what I needed...Thanks! My apologies, I misread your 2nd post. Seriously, My apologies....long day i guess. I'm going to eat some dinner, regroup, come back and dive into DOM parsing. This is a really good community and great resource.
  11. why are you guys trying make me out to be a bad guy? I thought this was a place to go for help, not ridicule. If I go unprotect the images would that prove I'm telling the truth? jeez. *****Images are now unprotected***** do you feel better? Have I broken some message board rule? Or am I being attacked for not being a php guru? I didn't ask anyone to write the code, just to point me in the right direction. Apparently you'd rather try to continue to prove what I've already admitted, which is I know very little about real php coding. I wasn't questioning anyone to say they were wrong, I was questioning because i didn't understand.
  12. I do have access to the site, they are seperate domains: tigerfitness.com & tigerfitnessforum.com/blog The store is a Volusion store, it started long before the forum & blog. I'm not doing anything shady if that's what you're saying. I just need help getting started in the right direction. I'm trying the cUrl option because after some google searches, it seemed to accomplish what i wanted. I'm trying this way, because i obviously don't know of a better way...lol
  13. Xyph - You are absolutely correct, I do have limited knowledge of PHP. Which is why I come here, to get pointed in the right direction. Due to the limited knowledge, I'm not sure how to tackle the issues at hand sometimes. So I come here, describe my situation, and hope someone can point me in the right direction. Google searches bring back php keywords for me to look up and learn about. I wasn't rejecting your solution, I thought you were saying to use an xml feed to grab the 10, 20, 30 most recent products. But that's not what i want, I want to grab information that is put on the homepage each time the homepage is requested. To simplify what I want: go to http://www.tigerfitness.com , refresh the page a couple times and you will see the grid of products changes each time. The grid is pulling from New, Featured, and Hottest selling products. All I want to retrieve from the front page are the product images and the product page they link to. Once I have that, I'll display in a random image box or slider on different pages of the blog & forum. The images need to maintain their links so that when someone clicks on a product image in the blog it will take them back to the store. Now...Given that information, would you still use an xml feed or would you go another route? It seems like if I wanted to get any product from the store, then maybe using the xml feed would be the way to go. But I don't want to pull in old products, just the latest and greatest..lol If I am wrong or confused, then tell me and explain to me how I'm wrong so i can have a better understanding. I'm a fast learner, but every now and then having someone explain how they got from point A to point B really helps fill the gaps. :-)
  14. Xyph, I need to grab the images with their links to product pages from the homepage of the store. Then show them in a carousel or as related content to posts on the blog, which is a separate domain. When someone clicks on the product image in the blog, I want it to take them to that products page on the store. The homepage of the store changes everytime someone visits the store because the products are displayed in tables based on featured, top sellers, etc. So simply grabbing the data from the database isn't going to help my situation....at least I don't think so (but I've been wrong before).
  15. Thanks Mike, I'm going to work on that now. I'll post back here with the results.
  16. Thanks Mike. I was using preg_match late last night and I kept getting a result like this: Array ( [0] => Array ( ) ) Obviously I was doing something wrong, but I'll use the link you sent to me. That link looks like it will be more useful to me than php.net. Php.net has good examples, but it 's over my head sometimes and the people that respond on the pages offer up more advanced options, which is fine, but I'm a relative noob and it gets confusing - quickly! lol
  17. Thanks Razor. The store is a Volusion store, unfortunately it doesn't have any built in RSS, XML, or API applications. I'm the store owner, so it's ok :-) I'd much rather just pull in the data that I want, instead of filtering it if possible. What I needed more than anything was just to be pointed in the right direction and it looks like scraping/parsing is what I need to be looking for. Thanks!
  18. I have 2 sites. 1 site is a store the other is a blog. The homepage of the store shows random product images. Each image links to it's product page. I'm using the code below to get data from the store homepage into a variable: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.somesite.com"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); ?> I can echo $output and see the page displayed on my page. So that part is working. On the blog, I want to display random products and link them back to the store. How can I extract just the images & their page links from the $output variable?
  19. Thanks for a quick response. Not sure I know what you mean though. It sounds like what you're suggesting will display the image on SiteB, then link to where the image is stored in the directory vs. the product page. If that's not what you mean, can you give me an example or elaborate your explanation a little more for me? Thanks.
  20. I have a supplement store that we'll call SiteA . On the homepage there is a list of featured and best selling products with images. I have a separate blog that we'll call SiteB. I want to get the images and the url they link to (for the product page) from SiteA and display them on SiteB. So that when a user is browsing SiteB and they click on one of the product images, it takes them to the correct product page. I have a script where I can manually accomplish this. However, since the content on the homepage of SiteA is always changing, I'd like to automate this process. For example: If you do a google search for "php", then click on "images" at the top, you will see a list of images relevant to PHP. If you click on any one of them, it takes you to that images page. That is what I want to essentially accomplish. Any suggestions?
  21. dcro2 - as usual, it's working pefectly now! Thanks!!!! I have a calculation issue I might throw your way in a bit.
  22. dcro2...glad you're here lol Here is the form that is pulling colors from the 'color' table. <table width="500" border="1" cellpadding="10"> <tr> <td>Color Options:</td> <td> <? $result = mysql_query("SELECT * FROM colors"); while ($row = mysql_fetch_assoc($result)) { echo '<input type="text" name="color[]" value="' . $row['color'] . '"/><br />'; echo '<input type="hidden" name="id[]" value="' . $row['id'] . '"/>'; } ?> </td> </tr> <tr> <td> </td> <td><input type="Submit" value="Update Colors"></td> </tr> </form> </table> All I want to do is edit color names. For example, if someone misspells "yelow", I want them to be able to type in the correct spelling "yellow". Once the correction is made, they click submit and the table is updated. However, with the current setup, this is what I get when I echo the query: UPDATE colors SET color='Candy Apple Red' WHERE id = '193'UPDATE colors SET color='WHITE' WHERE id = '193'UPDATE colors SET color='GREEN' WHERE id = '193'UPDATE colors SET color='Candy Apple Red' WHERE id = '192'UPDATE colors SET color='WHITE' WHERE id = '192'UPDATE colors SET color='GREEN' WHERE id = '192'UPDATE colors SET color='Candy Apple Red' WHERE id = '191'UPDATE colors SET color='WHITE' WHERE id = '191'UPDATE colors SET color='GREEN' WHERE id = '191'
  23. As you can see, this array is setting each colorvalue to each idvalue. <?php include("config.php"); include("db.php"); $arrid=$_POST['id']; $arrcolor=$_POST['color']; foreach ($arrid as $idvalue) { foreach ($arrcolor as $colorvalue) { $sql = "UPDATE colors SET color='$colorvalue' WHERE id = '$idvalue'"; mysql_query($sql) or die("Error: ".mysql_error()); echo $sql; } } header("Location: " . $config_basedir . "adminhome.php"); ?>
  24. I have a table called "colors". It has 2 columns, id and color. All I'm trying to do is pull the data into the form, then edit the colors (for example - misspelled, etc.) Then submit it back to the table. Here is the code that pulls the data into a form so I can edit it: <form action="adminupdatecolors.php" method="post"> <table width="500" border="1" cellpadding="10"> <tr> <td>Color Options:</td> <td> <? $result = mysql_query("SELECT * FROM colors"); while ($row = mysql_fetch_assoc($result)) { echo '<input type="text" name="color[]" value="' . $row['color'] . '"/>' . $row['id'] . '<br />'; } ?> </td> </tr> <tr> <td> </td> <td><input type="Submit" value="Update Colors"></td> </tr> </form> </table> Here is my update script: <?php include("config.php"); include("db.php"); $id=$_POST['id']; $color=$_POST['color']; $result = mysql_query("SELECT id FROM colors ORDER BY id DESC LIMIT 0,1"); if ($row = mysql_fetch_assoc($result)) { $id = $row['id']; } $sql = "DELETE FROM colors WHERE id='$id'"; mysql_query($sql) or die("Error: ".mysql_error()); foreach ($color as $colorvalue) { $sql2 = "INSERT INTO colors (id,color) VALUES ($id,'$color')"; mysql_query($sql2) or die("Error: ".mysql_error()); } header("Location: " . $config_basedir . "adminhome.php"); ?>
  25. My apologies... The question is: How do I run a check to make sure the quantity ordered is equal to or greater than the minimum qty required to purchase the product?
×
×
  • 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.