Jump to content

WarKirby

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Everything posted by WarKirby

  1. Does this apply to functions too? Because I seem to have gotten that part working but I'm still getting an error from the same line, just apparently at a different part of it now. I used the function exactly as you put it in the second example, as well as the global definition at the top. global $dbProductsTable; $dbProductsTable = 'tblProducts'; //stuff in between function isValidProduct($input) { global $dbProductsTable; $test = mysql_query("SELECT FROM ".$dbProductsTable." WHERE articleNumber=".QuoteSmart(trim($input))) or trigger_error("Query Failed: " . mysql_error()); if (mysql_num_rows($test) > 0) { return TRUE; } return FALSE; } The errors I'm now getting: The string there is just 9 a's in a row, for testing. I can see the table name is going in properly, do that's now working, but I'm not sure what else isn't. QuoteSmart is a function in the same file to protect against injection attacks, which reads: // Quote variable to make safe function QuoteSmart($value) { // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not integer if (!is_numeric($value) || $value[0] == '0') { $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } any idea what's wrong now? Did I misunderstand something again ?
  2. Ok, I had a look, you were right. I amended my query to this, but it still doesn't seem to work: $test = mysql_query("SELECT FROM ".$GLOBALS['$dbProductsTable']." WHERE articleNumber=".QuoteSmart(trim($input))) or trigger_error("Query Failed: " . mysql_error());
  3. Ok, gave that a try. the resulting extra error: But I swear it's defined. I have this at the top of the file $dbProductsTable = 'tblProducts'; Possibly relevant, this function is in a file which I'm referencing from my main script, via require_once. As far as I understand from how it works, that shouldn't affect anything though.
  4. I'm not stupid Of course it's defined. This is just a function out of the whole script. That variable is defined at the top of the script, not shown in this snippet. See anything else that might be causing it ? Edit: Oops, I missed the other part syou said. trying it now
  5. Afraid I'm having an issue with this solution. unsolving for now This is the function I wrote, seems simple enough: function isValidProduct($input) { $test = mysql_query("SELECT FROM ".$dbProductsTable." WHERE articleNumber=".QuoteSmart(trim($input))); if (mysql_num_rows($test) > 0) { return TRUE; } else { return FALSE; } } it's returning an error when it gets called though: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/www/users/warkirby/testing/db.inc on line 41 any idea what might be wrong here ?
  6. I think you need some color coding and minor text decoration (bold, etc) on the name and subject line. I tried a post and the name/subject on it looked like just another line of plain text in the post. Also, an "Expand all images" (in this thread) button would be useful
  7. MY opinions, which are by no means law or fact: I think you should put the contact form only on the Contact page. Also left-align the input labels, make the Comment textarea significantly larger (especially in width), and add a little more space between all the input boxes in the form Also, not really about the website, but your offering Educational services seems a bit odd for a janitorial company. What does that involve ?
  8. This is what I'm saying. It IS reasonable to expect that, but many people still won't. That's just how people are. Not really much that can be done about human nature. So I'm making a suggestion to deal with it, for the sake of practicality.
  9. Agh. It just worked. I have no idea why. I'm editing some PHP farther up the file. I'm thought I didn't do anything that would change this, but the forms just suddenly started working. And of course, if I don't know how I fixed it, I'll probably break it again just as easily
  10. Fastest solve ever. hooray. I would still like to know about the behaviour of isset in this situation, if only for curiosity's sake
  11. I'm looking for a simple way to check if something exists in a table. For example, my products table has articleNumber as the primary key. I want to check if a given product exists, so I'm trying to check if a supplied articlenumber is found in the database What I'm thinking of doing: $var = mysql_query("SELECT FROM tblProducts WHERE articleNumber=".$TestProduct); if (isset($var)) ... Am I correct in thinking that isset($var) will return false if no matching record was found in the table? or will I need to do this some other way ?
  12. Sadly, this has not solved it I tried using all the CSS lines it suggested and changing the HTML appropriately. Also for good measure of testing, I tried using the html provided in that example. Neither part worked. It looks like this: Here's the HTML I'm using <form action="<?php echo $PHP_SELF;?>" method="post"> <label for="pArticle">Package Article:</label> <input type="text" name="pArticle" size="9" maxlength="9"/><br /> <label for="cArticles">Contents:</label> <textarea name="cArticles"></textarea><br /> <input type="submit" name="submitbutton" id="submitbutton" value="Add Package"> </form> <form> <label for="user">Name</label> <input type="text" name="user" value="" /><br /> <label for="emailaddress">Email Address:</label> <input type="text" name="emailaddress" value="" /><br /> <label for="comments">Comments:</label> <textarea name="comments"></textarea><br /> <label for="terms">Agree to Terms?</label> <input type="checkbox" name="terms" class="boxes" /><br /> <input type="submit" name="submitbutton" id="submitbutton" value="Submit" /> </form> And the CSS: body, body table { font-family: "Times New Roman", Times, serif; font-size: small; } .xsmall { font-size: x-small; } label{ float: left; width: 120px; font-weight: bold; } #submitbutton{ margin-left: 120px; margin-top: 5px; width: 90px; } input, textarea{ width: 180px; margin-bottom: 5px; } textarea{ width: 250px; height: 150px; } br{ clear: left; } Any idea what I've done wrong ?
  13. Agreed. I've written and run a test script doing pretty much that, and so far it's perfect. Finished in about 10 seconds (including ~9700 echo calls). Not run anything on my live databse yet, but I'm confident that this part at least will go smoothly when I do
  14. Hi everyone. I found this place through a google search for "mysql help forum". It was the first one on the list with non-broken registration, and which seemed active. I've learned how to find an active forum pretty easily. Usually, I pick a couple of the most active forums, and see how many posts they've had in the past 24 hours. <5 is a fail, and phpfreaks passed. I'm a jack of all trades, in terms of digital content. I do texturing, modelling, animating, and scripting. Right now, I'm learning HTML/CSS/MYSQL (they seem to be all linked together) primarily out of necessity, as my online business has fallen on hard times and I can't afford to hire someone to do backend stuff as I had done in the past, which I need for my second resurrection. So far it's a decision I don't regret and I'm learning plenty. As of today thanks to the help I've recieved so far, I have disabled adblock here. I'll probably donate a little if phpfreaks continues to be helpful, since I'm profiting a little from things I learn.
  15. Still kind of new to mysql. I'm atm working on a project that I originally paid someone else to write for me, when I knew nothing. One thing I've noticed in the PHP scripts he wrote, is the use of mysql_close($db); near the end of every script which connects to the database. The tutorials I've been learning from so far haven't mentioned this function, but I'd hazard an educated guess that it closes the mysql connection. I'd like to ask, what exactly is the need/purpose for this? Is there a particular need to close connections? Does something happen if I don't? Will connections close themselves anyway after some timeout? Is there anything I haven't asked that I should know about connections? Thank you in advance for any replies.
  16. Although it seems reasonable in theory, it doesn't really work in practice to expect everyone to go back and mark their threads solved after they get an answer. I think it would be a good idea for threads in any help forum to be automatically marked solved if X period of time (maybe 2 weeks ?) passes without any posts, and there's at least one reply from someone who isn't the OP. That would cover most of the threads which never get marked appropriately. For the occasional cases where someone posts a question, and then an hour later posts "nevermind, I figured it out" you could probably rely on the report tool for people to notify admins that a topic should be marked solved.
  17. Thank you for the reply. I was honestly more just trying to see if I could do it this way than anything. Since this form is entirely for my own covenience and will never be publicly available, I can live with having to be a little more careful. ATM, I'm not prepared to go and learn javascript on top of what I'm already doing, just for this. Perhaps in the future though. Another quick question, just for clarification. If I hit enter while typing in a textarea, will a linebreak be submitted to the php script processing it at that point? And Is it going to be alright to use: explode("<br />", $textFieldName); in my php for the above case ?
  18. That looks perfect, excellent thank you. I'll mark solved once I've tested it thoroughly.
  19. Hi everyone. I'm trying to create a textarea in a form that will accept a list of strings, each exactly 9 characters long. It seemed like the best way to do this was a textarea with 9 columns, and hard wrapping. So that it will force a linebreak every 9 chars, and I can use explode to parse it on the linebreak in PHP. It doesn't seem to be working as expected though. firstly, I noticed that it wasn't wrapping at all. I was on firefox 3.0.somethinorother. I upgraded to the newest version and now that works, but I guess this means older firefox versions are bugged to not use wrapping properly. Secondly, even now that it is working, it seems that despite the 9 columns, I can type 11 characters per line before it wraps. Is this feature just unreliable? Ought I to parse the data some other way instead?
  20. Hi all. I'm trying my hand at making a simple input form. The formatting isn't going so well though. It looks like this: There are a few problems with this: 1. The textarea next to Contents isn't aligned with the one above it. 2. Contents is at the bottom of the textarea, not the top 3. The lower button is left aligned My HTML for this is: <form action="<?php echo $PHP_SELF;?>" method="post"> Package Article: <input type="text" name="pArticle" size="9" maxlength="9" /><br /> Contents:<textarea cols="9" name="cArticles" rows="10" wrap="hard"></textarea><br /> <input type="submit" value="Add Package"> </form> The limits are deliberate. I'll be using this for inputting strings which are exactly 9 characters long, no more and no less. I want the bottom box to force a linebreak every 9 chars and as far as I'm aware, the above code should do that. I am using a CSS, so I figured I'd take a crack at fixing it. I added these two lines to my CSS: textarea { text-indent: 80px; } input { text-indent: 80px; } And that failed miserably. The result was: I don't understand why the textarea or upper box didn't even move at all. Or why the button at the bottom didn't entirely offset, instead just enlarging itself, Here is roughly how I want it to look (done in photoshop) Can anyone tell me what I need to do to my CSS to make it look like the third picture ?
  21. I think the right one looks too stylish. The left one is more systematic and simple, which I like. it's more easily readable, isn't trying to be flashy. A button shouldn't be flashy, it should just do it's job, I voted left
  22. Oh, neat. And just to be clear, that will populate the auto increment field in the new table appropriately, yes ?
  23. I was planning to do all tests and stuff on a backup of the live database first, and then run it on the live one when I'm sure everything is fine. That a bad idea? Does this mean the auto increment column won't auto fill itself when it's added? I was hoping it would do that. So if I understand right, I just run a loop that copies all the data one row at a time from the old table, to the new? (ordered by date of course) And I don't put anything into the auto increment column, because it will auto fill itself as each row is added?
  24. My mysql version is 5.0.67-log source distribution Apologies for the double post, was going to edit this into the OP but it seems I can't now.
  25. Hi everyone. I'm very new to mysql and php, learning as I go. Working on a database which has a problematic design oversight. The primary key is a combination of two fields, on the assumption that these fields would never be the same, but that is not the case as I find the need to create multiple records with identical values in these fields So I want to alter this table, to add a new AUTO INCREMENT column, and change the primary key to that. The table currently has just under 10,000 records in it which are valuable, so I can't afford to mess this up. Can anyone advise as to what I should do? I'd assume the ALTER query will be needed. Thank you in advance for replies
×
×
  • 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.