Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. Ok, I see the ' ' and have tried those as well but still get the same error: [quote]Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home2/wwwxxxx/public_html/category-page2a.php on line 25[/quote] I'm using this same code (which is for pagination) in another page and it works fine. However, it does not have the WHERE clause in it. Here it is: [code]$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM plateau_pros"),0);[/code]
  2. When you say it works... what do you get? I just get errors as posted.
  3. Yeah, getting the $cat_id from: [code]$cat_id = is_numeric($_GET['categoryid']) ? $_GET['categoryid'] : 0;[/code] Also, I did try that slight modification of the query code you suggested already and produced the same error.
  4. I'm trying to get a count of results from a database containing category ids so I can set this variable for the pagination. It keeps giving me an error and, to me, the query looks fine: [code]// Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT (*) as Num FROM members_cat WHERE categoryid={$cat_id}"),0);[/code] [quote]Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home2/wwwxxxx/public_html/category-page2a.php on line 24[/quote] Help?
  5. roopurt, thanks for the post. I think we're getting closer. Here's what it produces: this line: [quote]$cat_id = ValidateCatID($_GET['categoryid']);[/quote] gets this error: [quote]Fatal error: Call to undefined function: validatecatid() in /home2/wwwplat/public_html/category.php on line 9[/quote]
  6. Yeah, the link was just an example. If you go here: [url=http://www.plateauprofessionals.com/index2.php]http://www.plateauprofessionals.com/index2.php[/url] and click on one of the category links then that's the trigger. Ok, about the code. I left everything out after the 'else' statements as it's just a bunch of HTML to layout the page and display the results using $var tags. Works fine so didn't bother pasting that into the post. Your query code looks backwards to me. However, i'm a noobster so all this is a bit backwards. The data I want is in the plateau_pros table, not the members_cat table. The member 'id' is stored in both those tables which is the 'connecting point' between the two. When someone clicks on the category link it should pull all memberid's from the members_cat table then cross reference those with the plateau_pros table to summon the data about each member that would then be displayed in the page. Make sense? The other question is if i'm passing the category id to the category.php page properly so the query knows which category to pull from.
  7. ok, I have four tables like this: category              member_cat          plateau_pros        specialties ==========      ===========        =========      ============ categoryid --+                id            +--  memberid    --+    id category                |  memberid    >-+    name        +-<  memberid                             +-< categoryid        title                speciality                                                       company                                                         phone                                                         email                                                         details                                                         image I want to pull data from the members that match a specific category. I have 4 categories number 1 - 4 for their id's. My link to the category display page is like this: [quote]http://www.nameofsite.com/category.php?categoryid=1[/quote] I'm not sure how to get the category id passed into the query so it pulls the proper results. I have this query i'm trying: [code]$sql = "SELECT firstname, lastname, business, title, city, memberid, photo FROM plateau_pros FROM plateau_pros, members_cat WHERE members_cat.memberid = plateau_pros.memberid ";[/code] if ($num_rows == 0) {   echo "There are currently no professionals associated with this category."; } else { where the results would be dispursed throughout some HTML code which works fine if I just query SELECT * FROM plateau_pros which draws all the members. So, 1) what's the correct way i'd set my link to the category.php page to summon the category id, and 2) how should the query be written to cross reference the member's associated with the category id? Thanks!
  8. Toon, I emailed you some questions. Having a bit of a challenge getting the class file and function set up properly. The upload is failing in the final stages. Just needs some tweaking on my coding i'm sure.
  9. Ok, that produced this: [quote] Problem is this: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 '' at line 1[/quote]
  10. Sorry about that. I didn't preview the post first. Not sure why the code all freaked out. Anyway, I fixed it so it's readable now. Ok, i'll check the query for success and post back.
  11. Toon, I emailed you on that offer. Let me know if you get it. Thanks!
  12. I'm confused since I have several working scripts using identical code. But for some reason I can't see why this setup is a problem: [code]<?php $sql4 = "SELECT * FROM plateau_pros WHERE username=".$SESSION['username'].""; $results4 = mysql_query($sql4); while ($row4 = mysql_fetch_array($results4)) { echo "<table width\"500\" border=\"0\"> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Name: </b></td> <td bgcolor=\"#e0e0e0\"><class=\"bodytext\">". $row4['firstname'] ." " .$row4['lastname'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Business: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">testing testing testing ". $row4['business'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Title: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['title'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Phone: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['phone'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Mobile:</b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['mobile'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Fax: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['fax'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Email: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['email'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>URL: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['url'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Details: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['details'] ."</td></tr> <tr><td bgcolor=\"#c0c0c0\"><class =\"bodytext\"><b>Specialties: </b></td> <td bgcolor=\"#e0e0e0\"><class =\"bodytext\">". $row4['specialties'] ."</td></tr> </table>\n"; } ?> [/code] This returns this error: [quote]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/wwwxxxx/public_html/members-view.php on line 271[/quote] Guidance? :)
  13. I'm very interested in this thread cuz i'm also looking to generate thumbnails on the fly and haven't gotten any responses to my other posts concerning this topic. I downloaded the phpThumb() files and can either post it or upload as an attachment if the forums allow. Like you, Peter, I need the <img src to produce an image from a query instead of having the name of a specific image in the <img src tag. I haven't fully set up the phpThumb yet but noticed the demo has a ton of broken links for the images. No images came in my download file. That's a red flag. Hope this isn't a waste of time.
  14. Barand: I commented that out because it was producing an error. Not 100% what it said but something about it not being a valid argument. The 2nd query was also an experiment at a time that I was having trouble getting the images to show up. That's been rectified now. I know the code is sloppy as it's always a work in progress while i'm learning and experimenting. What i'm trying to do now is run the query that matches all the members that are associated with a particular category whereas the category ID is passed in a hyperlink.
  15. Ok, I inserted the query and made some minor adjustments. Unfortunately it's not producing any results. Here's the full snippet of code: [code]$sql = "SELECT p.* FROM member_cat AS mc ON ( mc.categoryid = c.categoryid ) LEFT JOIN plateau_pros AS p ON ( p.memberid = mc.member_id ) WHERE mc.categoryid = '4'"; $results = mysql_query($sql); //$num_rows = mysql_num_rows($results); $sql2=("SELECT photo FROM plateau_pros WHERE photo='photo'"); //$result2 = mysql_query($sql2) or die(mysql_error()); //$image = mysql_result($result2, 'photo'); //mysql_fetch_array($results); if ($num_rows == 0) {   echo "There are currently no professionals associated with this category."; } else {[/code] After the 'else' it runs the code to display the results in a bunch of HTML. Also, please note I modified your code references as the actual table names were slightly different than what I posted. The only change is this: 'members' should be 'plateau_pros'
  16. Ok, cool. I do see in the query where you've set the category id at '4'. The category id will be passed with the url so it won't always be '4'. There's 1 thru 4 for the category id's being passed like this: [quote]http://www.mysite.com/category.php?categoryid=1,2,3 or 4[/quote] How would this affect your query code?
  17. I need to do a query where someone clicks on a category link that carries a 'category=4' id which is passed to the next page containing the query. My tables are set up like this: [pre] category        member_cat        members        specialties ==========      ===========        =========      ============ categoryid --+  id            +--  memberid  --+    id category    |  memberid    >-+    name        +-<  memberid             +-< categoryid        title            speciality                                     company                                     phone                                     email                                     details                                     image [/pre] The query needs to pull all members that are associated with that category id which, in turn, is then displayed via HTML in a neat little profile for each person it returns from the query. Need some guidance on this in the form of a working example so I can put it into my PHP memory banks. Thanks!
  18. I have a page displaying member profiles along with a photo of each. I'd like the photos to be able to be displayed in various sizes throughout the site but don't want to create multiple images of each to do so. I have this function that resizes but the method it's using is by actually naming the image you want resized. Instead I want it to extract the image name from the database then display the resized image in the page where I have the <img src tag. Here's the function code: [code]<?php function imageResize($width, $height, $target) { //takes the larger size of the width and height and applies the  formula accordingly...this is so this script will work  dynamically with any size image if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage); //returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the return "width=\"$width\" height=\"$height\""; } ?>[/code] Which uses this variable: [code]$myphoto = getimagesize("images/photo/imagename001.jpg");[/code] In order to get the current image size/dimensions. Here's the HTML tag suggested: [code]<img src="images/photo/image001.jpg" <?php imageResize($myphoto[0], $myphoto[1], 150); ?>[/code] My problem is that the name of the image is not known. Therefore I can't set that $myphoto variable. In my case the name of the image needs to come from a mysql query which returns the information from a field labeled 'photo'. The page will display several profiles per page. Therefore the image needs to be relevant to the profiles being shown. Right now the profiles are fine as far as displaying them in the proper order, etc. The only issue is the image resizing per image displayed. Help?
  19. Well, that was an adventure. During the update of MySQL we had a few issues with rebuilding Apache and all the various supporting modules on the server like GD library and other important items. Anyway, we were finally successful in getting MySQL to 4.1x and the code you posted worked like a charm. All 3 INSERT queries are running perfectly now so I can run my SELECT queries to display the proper data. [B]ALSO! An FYI for anyone reading this post. [/B] I was receiving errors when the INSERT queries were being run. After doing some serious research to find the source of this error: [quote]Column count doesn't match value count at row 1[/quote] It turns out that IF you have an auto-incremented 'id' field in your tables then you need to include that in your INSERT queries as a field even though you are not inserting data into that field. This is done by using a blank set of single quotes to signify the field. Like this: $sql3 = "INSERT INTO specialties (id, memberid, specialties) VALUES ([B][color=red]''[/color][/B], '$newid', '$specialties')"; This error kept popping up on 2 of my queries and caused a lot of delays and some grief. There may be another way to deal with this but I thought i'd pass this along to keep people from having the same issue. Thanks for the help! :)
  20. Ok, i'm using an older version. But, i'm updating right now to 4.1x and we'll see what happens. I have to restart some apache crap first. I'll post in a bit.
  21. Thanks for the post and the tip. I do plan on cleaning up the code and going to validation once I get all the queries for both insert and the select to work properly. I inserted your code in place of what I had for sql2 and get this error: [quote]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 'SELECT categoryid FROM category WHERE category = 'Health and We[/quote] That's all it showed. Looks like the message was cut off somehow.
  22. I saw this somewhere but can't find it for the life of me. Here's what I have. This query works fine now and inserts the proper id's and data into the database. However, the category [b]name[/b] is getting inserted into the 'members_cat' table instead of the [b]categoryid[/b] which, in turn, would enable me to do queries for memberid's that match that categoryid. Here's the queries: [code]// Run query $sql = "INSERT INTO `plateau_pros`(`username`, `password`, `confirmPass`, `firstname`, `lastname`, `email`, `url`, `business`, `title`, `address`, `city`, `zip`, `phone`, `fax`, `mobile`, `category`, `comments`, `specialties`, `photo`) VALUES('".@$_POST['username']."', '".@$_POST['password']."', '".@$_POST['confirmPass']."', '".@$_POST['firstname']."', '".@$_POST['lastname']."', '".@$_POST['email']."', '".@$_POST['url']."', '".@$_POST['business']."', '".@$_POST['title']."', '".@$_POST['address']."', '".@$_POST['city']."', '".@$_POST['zip']."', '".@$_POST['phone']."', '".@$_POST['fax']."', '".@$_POST['mobile']."', '".@$_POST['category']."', '".@$_POST['comments']."', '".@$_POST['specialties']."', '".substr(strrchr($eg_uploadFile1, "/"), 1)."')"; mysql_query($sql) or die(mysql_error()); $newid = mysql_insert_id(); $sql2 = "INSERT INTO members_cat (`memberid`, `categoryid`) VALUES ('$newid', '$catid')"; mysql_query($sql2) or die(mysql_error()); //experimental variable $specialties = $_POST['specialties']; //query to insert specialties $sql3 = "INSERT INTO specialties (id, memberid, specialties) VALUES ('', '$newid', '$specialties')"; mysql_query($sql3) or die(mysql_error());[/code] Once again, they work fine but I believe I need to somehow pass the categoryid from the form which is using a drop-down selection for the category. The values for each category selection are the names of the category.... not an ID number. This is what I have now: [code]<td> <select id="DropDown1" style="WIDTH: 230px" name="category"> <option value="Marketing" selected="selected">Marketing <option value="Professional Services">Professional Services <option value="Health and Wellness">Health &amp; Wellness <option value="Home Design and Improvements">Home Design &amp; Improvements </select></td>[/code] As a result, the 2nd query is NOT inserting the category name or categoryid. That table has 3 fields: id , memberid, categoryid of which id is auto-incremented. The id and memberid are being inserted but nothing for the categoryid. In the 'category' table there's just two fields: categoryid and category of which the latter holds the name of the category and the categoryid is autoincremented. There's currently 4 categories numbered, of course, 1 thru 4. Those are the numbers that need to go into the members_cat table. I know this is long winded. Hope it makes sense but figured I needed to explain all aspects. Thanks.
  23. This may help. It's the <form> code that is requesting the username/password. [code]<form action"<? print $PHP_SELF ?>" id="Form1" style="WIDTH: 100%" name="Form1" method="post" > <table id="Table1" cellspacing="0" cols="2" cellpadding="0" align="center" border="0"> <tbody> <tr> <td> User name:&nbsp;&nbsp;</td> <td> <input id="Text1" name="username" value="<?= @$_POST['username'] ?>"></td> </tr> <tr> <td> Password:</td> <td> <input id="Password1" style="WIDTH: 155px; HEIGHT: 22px" type="password" size="21" name="password"></td> </tr> <tr> <td> </td> <td align="right"> <br> <input id="Submit1" type="submit" value="Login"></td> </tr> </tbody> </table> </form>[/code] The code for the login form parsing is: [code]<? // Declare loginError so a value is always available $loginError = ""; // Turn on magic quotes to prevent SQL injection attacks if(!get_magic_quotes_gpc()) set_magic_quotes_runtime(1); include 'dbconfig.php'; // Connect to database $eg_objConn1 = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname, $eg_objConn1) or die(mysql()); // Validate users input if(!empty($_POST)) { // Check username has a value if(empty($_POST['username'])) $eg_error['username'] = "Please enter a user name!"; // Check password has a value if(empty($_POST['password'])) $eg_error['password'] = "Please enter a password!"; // Check if any errors were returned and run relevant code if(empty($eg_error)) { // Get Record Set $sql = ("SELECT * FROM `plateau_pros`  WHERE username = '$username' AND password = '$password'"); mysql_query($sql) or die(mysql_error()); $results = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows($results) or die(mysql_error()); //$eg_Result1 = @mysql_fetch_array($eg_recResult1, MYSQL_ASSOC) or die ('Error in query: $eg_Result1. ' . mysql_error()); if ($num_rows == 1) {       // Enable sessions if (isset($_SESSION['loggedin'])) {   header("Location: members.php");   exit; } else {   $_SESSION['loggedin'] = $_POST['username'];   // Go to page header("Location: members.php"); break; } } else { $loginError = "Your user name and password do not match any in our database!"; } } } ?>[/code] Each time i've tested i've logged in first so it would pass the 'username' variable. However, that's not happening.
×
×
  • 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.