Jump to content

nethnet

Members
  • Posts

    284
  • Joined

  • Last visited

Everything posted by nethnet

  1. You can make certain colors be considered transparent with GD Library, but I think the best bet for you would be to just actually open the images up in PhotoShop and erase the white pixels surrounding your image. Put the image on a layer on top of a dark background in PhotoShop and you will see that the outline is part of the image file, not a malfunction with GD Library. Doing this with GD would be very cumbersome, as I highly doubt that each of those pixels surrounding the image are the EXACT same color. They are most likely varying shades of light gray and white.
  2. Are you trying to get what is in the rates1 field of your form after it is submitted? Or are you trying to dynamically grab the value of that field for use on the current page?
  3. Yes, of couse you can name $row anything you like. Also, if you will only expect one row to be returned from the query, you don't need to use a loop to define $row. Just doing the following will work perfectly fine: <?php $result = mysql_query("SELECT * FROM users WHERE name='$user'"); if (mysql_num_rows($result) === 1){ $row = mysql_fetch_array($result); } else { echo "No user found."; } ?> You should always check to make sure the query returned something before using any of the mysql_fetch_ functions, as a query with 0 results will cause resource warnings. I simply checked to make sure there was exactly 1 row returned before passing the query resource to mysql_fetch_array().
  4. I'm with thorpe on this one. Leaving out the braces not only looks tacky (luckily this has no application to anything practical), but it also provides for a headache in debugging, as we can see. I had to run though each of those scripts a couple times just to make sure I was counting all of the braces correctly. But alas, let's not get distracted from the problem... It's possible that the lack of any output is an indication of a parse error, even though you say error reporting is turned on. Copy/paste your codes into a program like jEdit if you aren't already just to check for possible parse errors (most of these softwares have it built in). And if it looks good, then run the script with some control values. Supply inputs that would produce a known output, and follow the path of that schematic through your programming logic, placing echos along the way writing simple things such as "Looks like methodA() is returning false after all.." If none of these echo statements are printed back, then you know for sure there is a fatal error.
  5. Use Javascript then. Use an onSubmit() event handler in your form tag to run an error checking function in Javascript that checks to make sure the form doesn't contain any blank fields. If it does, throw up an alert() or something similar to notify the user to correct their mistakes. If not, proceed to submit the form. Since this is a matter of not moving to another page, you will need to use client-side scripting to accomplish this, not server-side. If you are gung-ho about using PHP to error check, you will need to use AJAX.
  6. Well, your first problem is that you are creating several forms on your page, but only having one submit button, and only ending one form with a </form> tag. Pushing the SUBMIT button might produce some unexpected results. In addition, it looks like you will generally be having multiple items show up on the page, yet each individual items form contains the same field names. This will make it difficult to extract any reliable data at all on your quotes page. I suggest that the first step you take is to restructure your form so as to eliminate any ambiguity. From the looks of your script, there is no real need for the SKU, Description, and Price fields in your form to begin with (obviously, if there is need for them to be there for other scripts you have, then this won't apply), so my suggestion would be to initiate your form before your while loop, and include your item information inside the loop, but not as form elements. From there, you could use either an ID number, or even the SKU number as your quantity fields name. <form action="quoter.php" method="POST"> <?php $query = "SELECT * FROM tbl_prods WHERE cat = 'fruit'"; $target = mysql_query($query); confirm_query($target); while($row = mysql_fetch_assoc($target)) { ?> <tr> <td><?php echo $row['sku']; ?></td> <td><?php echo $row['desc']; ?></td> <td><?php echo $row['price']; ?></td> <td><input name="<?php echo $row['sku']; ?>" type="text" value="0" size="3" maxlength="2" /></td> </tr> <?php } ?> </table> <input type="hidden" name="cust" value="<?php echo $cust; ?>"></p> <input type="hidden" name="reg" value="<?php echo $region; ?>"></p> <input type="submit" name="submit" value="Submit"></p> </form> And then on quoter.php you can just run a foreach loop through your $_POST superglobal, and discard anything with a value of '0' from consideration (as these will be quantities of 0). Anything with a value of 1 or greater should be processed with your quote script. quoter.php <?php $toquote = array(); foreach ($_POST as $sku => $quantity){ if ($sku == "cust" || $sku == "reg" || $sku == "submit" || $quantity == 0) { // Don't quote these since these obviously aren't quantity fields } else { $toquote[$sku] = $quantity; } } ?> The $toquote array would then contain all of the items from the form that needed to be quoted (meaning they had quantities greater than 0), accessible by their SKU number as that items key. Hopefully that helps! EDIT: Fixed a syntax error in the code. Fast typing FTL.
  7. Depends if you are looking for convenience or extendability. Javascript will be convenient because it will automatically pull the users local time, which it seems like you want. PHP will require you to ask your users to select a timezone so you can manipulate the server time, or else it will just use the server time. So in this sense, I would say Javascript. But, PHP datetime will be easier to implement in a script if that is your ultimate goal, such as recording this time to a database (in which case you might consider using MySQL's now() function). I guess it just depends how you plan to use it. @The Eagle - any user who denies Javascript in this age just simply shouldn't be allowed to use the Internet at all. That would solve some issues, wouldn't it? Theo
  8. Javascript would be your friend in this case, if the form validation doesn't require checking against a database. If it does, look into using AJAX to execute your PHP script that checks for errors so the user doesn't actually leave the form page. Theo
  9. You may be better of just recording a users timestamp when they access a page while logged in, and track that in your database. After, say, 5 minutes of inactivity, you could consider them offline. This is how most online/offline schematics work. As far as I know there is no way to force a log off when a user closes a browser by simple javascript. Feel free to prove me wrong on that, though One method that does come to mind though would be establishing a simple AJAX 'ping' of sorts. While a user is logged in, you could be constantly pinging the server with a simple PHP file executed though AJAX. If the ping occurs every 10 seconds, you could consider any 'most recent ping' of a user that is more than 10 seconds ago to be indicative that they have either closed the browser, navigated away from the site, or logged out. I'm curious to see the resolution of this thread, though... Good luck, Theo
  10. Hi HopelessMike, Actually creating your survey page (the page which presents all of the questions to the user) isn't a matter of PHP coding. If you aren't familiar with HTML, look into this explanation of creating forms. Direct the 'action' of your form to somepage.php, which will contain the actual PHP code for the script. Using the $_POST superglobal array in somepage.php, you can get all of the information they submitted through the form. Run this array through a simple foreach loop (which will take each field one by one so you can extract the info) and write that to your text file. Something like this should get you started: <?php $writeline = ""; $handle = fopen("user_data.txt", "a+"); foreach ($_POST as $field => $value) { $writeline .= $field . ": " . $value . " / "; } $writeline .= "\n"; fwrite($handle, $writeline); fclose($handle); ?> This function will loop through all of the fields from the form that was submitted and create a string of text in the format of: Name: Peter / Age: 25 / Occupation: Designer It will then add this string of text to 'user_data.txt' (located in the same directory as the script). This file will contain ALL submissions of the form, each individual submission on a new line. You might also like to check the PHP manual for documentation on file functions. Filesystem functions at PHP.net Hope this helps, Theo
  11. Thanks for the reply. What exactly about the layout makes it seem so outdated to you? And could you elaborate on the whole 'hurt my eyes' bit? I'm not exactly sure how to take that as constructive. Keep the target audience in mind - this is an online game, geared towards the 13-20 age range. The bold typeface was a deliberate choice because of that. As for side-menus and such, those will follow on the members pages. The link provided is just for the landing page. Once I fine tune that, I will develop the actual layout of the members content, which will undoubtedly contain a proper logo, navigation system, etc. I basically just want a critique on the style and feel of this landing page to use as a springboard for the main content of the site. Thanks again for your comment.
  12. Hi guys, I've re-lauched an old website of mine (go figure - it's called nethnet). The site is an online reality game based on a few popular reality TV shows (Survivor, Big Brother, Amazing Race, etc.) I've thrown together a few different themes for the layout/colors/etc, but I want to get some outside feedback before I continue developing the rest. The link to the website is below: http://www.nethnet.com And yes, there are no links to the rest of the site yet. I've been doing a lot of programming to get the games to work, but I wanted to solidify the theme of the site before actually making the members-only layout. I was going for a sleek but simple look. Please don't comment saying "links are broken" or "just 1 page?" As I said, the only page visible to the public right now is this homepage. I want to get some solid critiques on the layout/theme/feel of the site before making anything else accessible. Thanks! -Theo
  13. Put those two lines of code before your if statement.
  14. @dreamwest, Thanks for the response. Unfortunately, the $_GET array is still coming up empty when /user/testuser is accessed. So my fears are true... it's not an issue with REGEX errors or anything. Something is going fishy with Apache itself. Any other input is appreciated... I have no idea where to begin with fixing this.
  15. That would only work if register globals was enabled. So, essentially, no. You could provide a link somewhere on your page that allows people to switch between the versions, and pass a flag in your URL. Something like.. ?switch=desktop $switch = $_GET['switch']; $mobile = ($switch == "desktop" && $mobile == TRUE) ? FALSE : TRUE;
  16. I feel like this is a really simple problem... I'm working with mod_rewrite and I've done so for years, and never had a problem. But all of a sudden on this new server, I'm having a problem getting the $_GET array to contain.. well, anything. Everytime a page is redirected, the $_GET array is empty. RewriteEngine on RewriteRule ^user/([a-zA-Z0-9]+)/?$ user.php?name=$1 The page is actually redirected to user.php without any problem, but when I try to pull out the $_GET['name'] data, it is empty, everytime. Am I doing something incredibly stupid? I'm hoping so... I really don't want to have to configure Apache or anything... Thanks in advance.
  17. Basically, pretty much every error encountered on my web server is a 403 - Forbidden error, even when the file does not exist and 404 - Not Found should be returned. It's crucial that the correct error code is returned, so that our automated debugging schema can notify us properly on the error. We don't want to be told 1,000 times a day that people are having trouble accessing a forbidden file when it doesn't even exist in the first place. The false errors started to be encountered after a .htaccess update involving a new mod_rewrite schematic. I'll post the entire relevant portion of the .htaccess file that was altered so that perhaps the source of the error can be found. Is there something wrong with the mod_rewrite that is causing a Forbidden error instead of Not Found? IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> ** lines edited to omit sensitive material** Options -Multiviews Options +FollowSymLinks RewriteEngine On RewriteRule ^home$ index.php [L] RewriteRule ^login$ register RewriteRule ^game/([0-9]+)/?$ game.php?id=$1 [L] RewriteRule ^error/([0-9]{3})/?$ error.php?code=$1 [L] RewriteRule ^user/([A-Za-z0-9]{4,14})/?$ user.php?name=$1 [L] RewriteRule ^stats/?$ /stats/index.php [L] RewriteRule ^([A-Za-z0-9]+)/?$ $1.php [L] ErrorDocument 404 /error/404 ErrorDocument 500 /error/500 ErrorDocument 403 /error/403 Is there something obvious that I'm missing here?
  18. Taken from the PHP manual: Warning Using persistent connections can require a bit of tuning of your Apache and MySQL configurations to ensure that you do not exceed the number of connections allowed by MySQL. As you stated, some pages use persistent connections and some don't. I would revert all connections back to the regular mysql_connect() and see if that doesn't fix the problem. Also, there is a big difference between the two. The major difference that I expect is impacting your script is the fact that mysql_pconnect() does not explicitly close its connections. And since you said you are interchanging the two connections, you could very easily exceed the max connection limit.
  19. This is a common error people run into when going from developing locally to publishing online. Check to make sure that there is no auto-appended prefix on your database name (some webservers to this). Also, this is sometimes caused by MySQL overload. Check with your webhost to see if there are any reported MySQL outages on the server. This has happened to me before and the solution was nothing more than waiting overnight for the problem to be resolved.
  20. This isn't the right forum for help with third party scripts such as this, but in general, Internal Server Errors are caused by malformed CGI scripts or invalid directives in your .htaccess file, etc. Have you done anything with your Apache configuration that could be throwing this error?
  21. "and" is not proper syntax for an If statement. Use "&&" instead.
  22. Hey guys, it's nice to return to PHPFreaks after a few years of not being here (well, to be correct, a few years of not REALLY being here... I popped in a few times and answered a random question or two). This site has gotten quite the facelift! It's nice to see that the website and forums are completely integrated now, although many of my favorite tutorials (and authors) seem to have vanished. It also seems like a few of my former companions on this site have gone MIA (toplay, shivabharat, and gizmola, to name a few...) Anyhoo.. life has finally offered me an era (momentary, may it be) where I can return to PHP coding so I hope to pick back up right where I left off on this site! Theo
  23. Hi, I'm having some issues with my web server in terms of 4xx errors. I've tried Googling this issue for a couple days now, but all I can seem to find is the exact opposite of my problem. I've recently implemented a complex mod_rewrite system on my Apache server to keep attackers from having access to the directory structure (or even knowing the structure for that matter). I've also implemented an automatic error schematic that notifies the administrators with a log of all Apache error codes received. In theory, this was supposed to reduce the stress for us in debugging broken links, etc, but it has created a bit more of a problem. An error 403 Forbidden code seems to be returned when a 404 Not Found would be appropriate. The mod_rewrite schema implemented reroutes URI's as such: /user/example/blog/test rewritten from user.php?id=example&method=blog&methodid=test And so forth. The base redirect is as such /anything rewritten from /anything.php (this is, of course, with exception of some critical directories that are not rewritten, such as /images, /css, /js, /inc, etc.) It is crucial that we have an error 404 Not found code returned when /anything is accessed and /anything.php doesn't actually exist. I'm assuming the server confusion revolves around the fact that no default index.php file exists in the /anything directory (thus returning Forbidden) but with the rewrite it shouldn't be trying to access this directory in the first place. Is there a way to force an error 404 instead of a 403?
  24. I'm confused by your script. Your form is submitted to searchDataBase.php and the search query from the form is set to the variable $search. So what exactly are your users searching through? From the looks of it, you're allowing your users to search through your database structure. In your SQL: "SELECT * FROM 'products' WHERE $search LIKE '%$searchterm%'" There are a few errors. If your customers are searching for a product name, for example, you'd need to rearrange your SQL a little bit: "SELECT * FROM `products` WHERE `name` LIKE '%$search%'" That way, the $search variable is used to search for the actual name of the product, and not for a column in your database called '$search'. This is, of course, assuming you have a column named 'name' with the products name stored in it. Theo
  25. Get rid of the semi-colon after your $chandle variable. You can't seperate functions from "or die()" with a semi-colon. This is all pretty elementary. If you keep getting errors based on your syntax I'd recommend looking over some introductory tutorials. It's unnecessary to post every syntax error you get on these forums when they're all pretty much the same. Be careful with your semi-colons.
×
×
  • 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.