Jump to content

BigMonkey

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Everything posted by BigMonkey

  1. Probably, but at least I should be consistent about it, right!?
  2. Thanks! That fixed it. I don't know why I thought is was the same, but I'll be reading about that more. I will also be reading about this. Thank you for the BRIEF responses without the clutter of unnecessarily technical details.
  3. This warning/error started about 2 days ago. Only one change has occurred on the server, and that is a change in the password. The script should fail long before it get to its current failure point if the password were the issue. <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $dbname = 'nameofdb'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname, $conn) or die('Error selecting DB.'); $query = "SELECT * FROM news_items"; $result = mysql_query($query, $conn) || die('Failed Query'); // Following line gives error "Warning...supplied argument is not a valid MySQL result resource..." print_r(mysql_fetch_row($result)); ?> I started with an only slightly more complex query and reduced its complexity until I had what is here. I verified that the script: * fails to connect to db if the password is changed to be incorrect, * fails to select the db if the name of the db is changed to be incorrect, and * fails to query the db if syntax errors are introduced into the query string. I have restarted the services hoping that might help, but it did not. Versions: WAMP5: Apache 2.2.6, MySQL 5.0.45, PHP 5.2.5 I have queried a number of time in the past without incident, so I'm confident that there error is something small, overlooked coding error or something. The error seems to indicate that there is something wrong with the query, but I don't see it. In case it matters, there *is* data in the database, so there is actually something to query. Does anything stand out for you? Thanks!
  4. Since this particular form sends the information to itself (action="test.php"), there is no second page. If JS in not enabled on the client machine, then that is the least of my worries, I suppose. But for those whose JS is enabled, I'd like to disable the SUBMIT button. I'm actually using code that was delivered for me to use in production (I think--no, SURE--it was harvested from another site altogether), so I've had to perform some cosmetic surgery on the existing code, plus I'm having to learn more PHP as I go. I smell a redesign... At any rate, if one of you has a snippet of code to demonstrate how I might accomplish this, I would be greatful.
  5. Bonjour, freaks! Given the following code, how can I cause the SUBMIT button to be disabled until the user begins to type into the textarea? The idea, of course, is that the textarea is a required entry and leaving it blank results in the inability of the user to submit the form. In this case, I'm using a quasi-pseudo-very-nearly-almost-sort-of dynamic page in which the form action calls the same page and the newly displayed information is based on the SUBMIT button having been clicked (thus giving it a value of TRUE). <?php if ( empty($submit)) { ?> <form action="test.php" method="post"> // this page is test.php -- it calls itself // the textarea is empty here; needs to be populated as a requirement. <textarea name="description" cols="40" rows="12"></textarea> <input type="radio" name="svcType" value="Service" />Service is required<br /> <input type="radio" name="svcType" value="Sales" />Supplies are required <input type="submit" name="submit" value="Send" /> </form> <?php } if (isset($submit)) { // I've been told I should change this to use the $_POST variable // cobble together return message // which is displayed on the "second page" } ?> The examples I've seen on the Internet fora contain heaps of JavaScript and, if there no elegant way to achieve the desired result in PHP, then JScript is just fine. However, I've seen a lot of examples, but none seem to apply to the specific result I desire here. Gently foisted into you collective laps for review,
  6. wildteen88, As terse and sparse as your reply is, it is nevertheless quite elucidating. So, regarding your moniker, were you a wild teen in '88 or are you now a wild teen BORN in '88? If the latter, you may find your moniker will not scale beyond next year. Unless, of course, you're 88 and you still feel like a wild teen in which case your moniker will be fine, but your body may not scale beyond next year.
  7. Perfect. I've tried turning on the register_globals and turning the register_globals back off in order to test the $_POST superglobal thingy, and both worked wonderfully. I read in the .ini file (sorry, laptop's a Windows gadget) the I should write code that avoids the necessity of turning register_globals ON, and in your respective replies you've mentioned security issues. So I've decided on using the safer of the two methods. Now, a side issue involves the use of isset() as it relates to the use of is_null(). In this case, is_null() appears to work more consistently than isset(), which, when employed, causes the new page many times to load is if the SUBMIT button were already clicked--as if the $submit / $_POST['submit'] were already set. Since, to newbies such as myself, the PHP Manual can become inscrutable very quickly, I'm rather counting on some additional feedback here. Thanks is advance.
  8. Hello, you freaks! In the following code--which works on the hosted production site (sometimes), by the way--does not seem to work on the test server. In this case, the test server is my humble laptop running Apache 2.2.4 and PHP 5, the latest stable release as of about a week ago. This must be an error common to newbies like me, so I'm counting on your collective experience to help with my profound information deficit. The thought here is that the form appears only if the Submit button has not be click; that is, it is not 'set'. However, once the Submit button is clicked, the variable $submit is set and the form disappears, revealing only the message stating the obvious. A very useful page, you see! The name of the page is 'test.php' and as you see from the form action, it calls itself. <?php if (isset($submit)) { ?> <form action="test.php" method="post"> <p> First Name: <input name="firstname" type="text"><br /> Last Name: <input name="lastname" type="text"> <input name="submit" type="submit" value="Send"> </p> </form> <?php } else { echo "You Hit SUBMIT!"; // You mother should be proud! } ?> Like I said before, it works on the production site, but not on my test server. I will add that the PHP engine appears to be working, as it will handle other PHP code just fine. Also, when I use is_null() in place of isset(), I seem to have fewer issues on the production server, but it still doesn't work on the test server. Thanks, Robert Nicholas
×
×
  • 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.