Jump to content

cags

Staff Alumni
  • Posts

    3,217
  • Joined

  • Last visited

Everything posted by cags

  1. Can you just clarify what you mean by this? Do you mean if they click a link as the page is still loading? That's what it sounds like you mean, but that doesn't make a great deal of sense to me. Also is that URL actually in the address bar, or is it created by a htaccess redirect?
  2. You took the wrong semicolon out. Mark Baker identified the right semicolon, but missed a close bracket. <?php if(isset($_REQUEST['firstname'])){ $findreq1->AddFindCriterion('MemberForename', $_REQUEST['firstname']); } ?> You'd find problems like that an aweful lot easier to spot if you'd have used multiple lines, even if you'd changed it back to single line afterwards
  3. Exactly. This is how I would do it... <?php if(isset($_POST['submit'])) { // process information and upload to mysql here (like the code we've been discussing) if(move_uploaded_file($_FILES['upload']['tmp_name'], $target)) { $feedback = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { $feedback = "Sorry, there was a problem uploading your file."; } } ?> <!-- the header / heading etc of your document here --> <?php if(isset($feedback)) { echo $feedback; } ?> <form action="" method="post"> <!-- your form info here, this is an example --> <input type="hidden" name="submit" value="1" /> <input type="submit" /> </form> <!-- footer/ rest of page here -->
  4. Few questions... [*]How are you trying to view the scripts? [*]Do you have Apache running? [*]Are you putting the scripts in the 'server root' directory (with xampp it's c:\xampp\htdocs\, with wamp it's c:\wamp\www\, not sure what it would be for easyPHP) [*]Are you trying to access them with http://localhost/ relative paths?
  5. I'm assuming that since you say you have copied files across and the problem persists, that it's just a typo, but I figured I should mention it anyway. The error message in your title says mysql_conenct.
  6. If you can't work out where it goes, then I have to say your understanding is probably not going to be what is required to make anything any more complicated than you have. Just looking at the line of code should make it fairly obvious where in your code it goes. We create a query string, then send the query string to the database. The code replaces your current call of mysql_query as it essentially does exactly the same thing only more securely. From what I can see of the code you have. The form POSTs to a seperate page which then processes the data and outputs success or failure. To stop it going to another screen you could self POST and process the information on the same page or you could redirect back after success. In order to make a pop-up window of a specifc size (something which I actually hate) you will probably have to use JavaScript as PHP cannot directly control the users browser.
  7. Basically what Maq was suggesting is that you have your code something like... <?php $sql = sprintf("INSERT INTO `test` (`name`, `address`, `email`, `upload`) VALUES ('%s', '%s', '%s', '%s')", mysql_real_escape_string($name), mysql_real_escape_string($address), mysql_real_escape_string($email), mysql_real_escape_string($upload)); mysql_query($sql) or trigger_error("Query Error: " . mysql_error(), E_USER_ERROR); ?> Looks a bit complicated, but basically sprintf is a function that will insert everything after the first paramter into the first parameter in position of special keywords in this case we have used %s, meaning it's of type string. So the 2nd-5th paramaters will be inserted into the first in place of the %s's. Technically speaking you can do what he suggested without sprintf, I just think it makes it easier to follow. The mysql_real_escape_string takes a string and replaces all MySQL special characters with the special character preceded by a backslash (so for example it will replace ' with \'). If you don't do this your site will be vulnerable to several types of sql injection attacks. With regards to my last post, that should have said "and a table for uploads", it was a typo, as you say 1 column should only contain one value. I have no idea, alas my crystal ball is in for a service so I can't automatically divine what is stored in a table based on a column name of one word. Note: If somebody mentions a function you don't understand, look it up on php.net, you will answer many of your own questions.
  8. Technically that was 97 over 2 days... but no I've not been busy, hence the fact I've spent so much time on the forums, lol. Boredom. Can you set the topic to solved if your sorted?!
  9. So near, yet so far trim($value,"0");
  10. Certainly worth bearing in mind, but in my opinion the fact that makes it so darn usefull. The amount of trouble I had keeping my file structure accurate with nestled folders and includes before I spotted somewhere the use of __FILE__ ... anyway I digress.
  11. I suggest you echo out the value of $listingtype before running the query so you see what is being sent. It should be impossible for the value to be anything other than 1 or 2. What is the datatype of the column id_ListType? If the value '1', or '2' is considered an invalid entry for that datatype it will set the column to the default value of that column. If the column is of type INT, the query should really be... $sql = "INSERT INTO table (id_ListType) VALUES ($listingtype)";
  12. Call me stupid, but I don't understand :-\ the only difference between the first and second table seems to be the order... which I assume (but haven't checked), would happen if you... SELECT * FROM `boards` ORDER BY `name`
  13. You may also find this usefull.. <?php echo __FILE__ ?>
  14. Yes, by moving the if($submit) {} block to the top of the page. Look at the page as PHP parses it in the order you had it originally. Load values from database, fill in form, update database. Now imagine it with the submit block at the top.... Update database, load values from database, fill in form.
  15. Do you have an input on the form with the name listingtype, other than the two listed in the exampe? A value of 0 should be impossible, as even if neither is selected I set a default value of 1.
  16. The URL does work, just the site struggles with bandwidth issues sometimes, just try it again.
  17. From what I remember, if you have multiple radio inputs on the page with the same name only one of them can be selected at once. So yes the example you have their is fine. <?php // this as your form <input name="listingtype" type="radio" value="1" /> text <input name="listingtype" type="radio" value="2" /> text // this is the value to insert into the database if(isset($_POST['listingtype'])) { $listingtype = $_POST['listingtype']; } else { // set a default value $listingtype = 1; // you could instead throw an error and make the user fill it in, // or whatever } ?>
  18. To match an anchor href which doesn't use quotes, could you not use space or > as the ending criteria and make the quote at the start optional? The only HTML I can think of that would work correctly are... <a href=http://www.google.com title="or some other attribute"> or <a href=http://www.google.com> Something along the lines of (this is untested, just theoretical). preg_match_all("/<a.*?href=[\"|\']?(.*?)[\"|\'| |>].*?.*?<\/a>/is", $page, $matches); But as previously mentioned I'm not that great with Regex, only wrote my first simple one earlier this week.
  19. It's possible you can just do another join. It all depends on exactly what results you want returning. But.... SELECT Players.ManufacturersModels_pk FROM Players LEFT JOIN ManufacturersModels ON Players.ManufacturersModels_pk=ManufacturersModels.ManufacturersModels_pk JOIN Manufacturers ON ManufacturersModels.Manufacturers_pk=Manufacturers.Manufacturers_pk JOIN Models ON ManufacturersModels.Models_pk=Models.Models_pk
  20. At what point did I suggest it was a problem with anything todo with the database? This is the type of code that would normally cause that error message... "INSERT INTO table (id_ListType, another_field) VALUES ('$listing_type'); or "INSERT INTO table (id_ListType) VALUES ('$listing_type', '$another_field');
  21. The error message seems to indicate that the purple bit has a different amount of entries to the orange bit. Obviously in your example code that's not true, but is it in your more complicated query? $sql = "INSERT INTO table (id_ListType) VALUES ('$listing_type');
  22. Why would preg_replace be better? If gordsmash just wishes to substitute one string for the other surely str_replace would be better.
  23. Do you actually need to run Regex? It looks like you're just trying to check for a stristr or do a string compare?
×
×
  • 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.