Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,449
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. the name of your file type form field is file. you would need to use that same name in the php code.
  2. your <form ....> tag is missing the enctype attribute that would allow a form to upload a file.
  3. reply to your reply made while i was typing the above. a) you should be learning php, developing and debugging php code on a local development system. apache/php/mysql can be installed on any current pc/laptop. b) you likely have access to a local php.ini on your hosting server where you can put your own settings. c) slow down, randomly trying things doesn't lead to solutions in programming. you must first define what you want, then write the code (see part of my reply above about what you want to do if the search term is empty.)
  4. the LOGIC conditions you just wrote are incorrect (by not posting a copy/paste solution for you to use, we are trying to get you to think like a programmer.) if there are zero rows, in the >= 0 test, you don't want the code to loop as there won't be anything to loop over. also, since the if(){} contains an equal to zero condition, the else{} won't ever be executed for the equal to zero condition. when the search term is empty, what do you want your page and your code to do? you have do define this first, not just try an make the messages go away. and please post your code in the forum using the forum's bbcode tags (the edit form's <> button).
  5. you can get php to help you find things like the $rows variable by setting php's error_reporting to E_ALL and display_errors to ON (in your php.ini is the best place to set these.) you no records found is due to a lack of program LOGIC in your code. when the code is (first) requested without a search term, what do you want the page to do? it's up to the LOGIC that you write to control what happens for that case.
  6. it's likely that the php code is using the short opening <? tag and it isn't enabled. what sort of opening php tag is there in the file? a full one <?php or a short one <? you can also look at the 'view source' of the page in your browser to confirm if this is the problem (you will see the raw php code.)
  7. header() statements can only be used before any content has been sent to the browser (content being anything other than a header.) do you have php's error_reporting set to E_ALL and display_errors set to ON so that php would be displaying an error when you have tried to use a header() after content has been sent to the browser? lastly, .html files by default are not passed to the php language engine to even parse the php code in it. have you configured your sever to invoke php for the .html file extension?
  8. everything is explained in the documentation - http://us1.php.net/manual/en/mysqlnd.install.php
  9. just because the mysqlnd driver is present, doesn't mean php was built to use it, there's a configure switch to get mysqli to use the mysqlnd driver (required with php5.3, built in with php5.4+.) to test if you can use the fetch_all statement - if(function_exists('mysqli_fetch_all')) edit: here's a dynamic way of using the most efficient retrieval method that is available in your php installation - http://forums.phpfreaks.com/topic/282959-odd-behaviour-on-webhost-server/?do=findComment&comment=1453950
  10. why do you have the above line, at line #2, in the posted code?
  11. what do you see when you do a 'view source' in your browser of the resultant output?
  12. a) if you are using the mysqli functions, you must use them for everything (you cannot mix in a mysql (no i) function.) b) the mysql(i)_real_escape_string function returns the value that has been escaped. you must assign that returned value to a variable that then gets used in the query statement. c) back-ticks ` are not the same as single-quotes '. it would be much better to rename your database column so that it doesn't use a reserved mysql keyword. back-ticks go around identifiers (database, table, and column names) when you use reserved keywords or other values that need special handling as identifiers. single-quotes go around literal string data inside a query statement.
  13. it's likely that one of your prepare, bind, or execute statements is failing, throwing an exception, and rolling back the data or perhaps you don't have pdo setup to throw an exception for those statements at all. your catch{} block isn't notifying you in any way that something failed AND you are allowing the remainder of your code to run if there is an error. btw - one of the points of using prepared queries is to reuse the prepared query statement, with multiple different sets of data values. the prepare and binding logic should be before the start of the foreach() loop. the only thing that belongs inside the foreach(){} loop would be the $stmt->execute() statement.
  14. whichever api you are trying to access will be documented as to the format and type of parameters it accepts and what format the data will be returned as and since it's likely you are not the first person to ever try to access whatever api you are trying to use, there's likely php examples posted on the api's web site, or just on the web somewhere, showing how you can send commands from and receive the data back into your script.
  15. not only that, we can only help you with code problems AFTER you have attempted to do something and you provide a statement of the symptom or error you got from that code.
  16. and how did you get it into the simple text file? how did you upload it? short-answer, there's nothing wrong with the syntax of the code (i just copy/pasted the php.net source and it works.) you likely ended up with some non-printing characters or some htmlentities as characters due to the methods used.
  17. it's not. most programming languages are simple compared to any linguistic language, and are far more constant and intuitively obvious (they have to be if a computer can parse the code and run it.) there are far fewer syntax/spelling rules that must be learned. however, we constantly see people that use the 'random trial' approach to programming. they keep trying different things they have seen or found without any idea what they mean or if they even contribute anything to the goal they are trying to accomplish. when code doesn't work, you must find out why and fix it, otherwise you are just wildly spinning your wheels wasting time that doesn't do anything toward accomplishing your goal. and while some computer generated error messages could be better, most, within the context of where they where detected, do provide information that points to the cause of the error.
  18. you would start with the first error message, read it, determine what it means, then find what about your code is causing it. btw - one of the points of using a prepared query is that you don't put data values directly into the query, but you put a place-holder into the query and bind the variable/value to that place-holder.
  19. you apparently copied some of this code from inside a function definition, where the return statement was returning a value the function produced to the calling code. you would probably want to remove the return instruction since the code is now in-line where it is being used instead of being inside of a function.
  20. i'm going to guess that the $slug variable contains some sql special characters that are breaking the sql syntax. the mysql_error() output will identify what is causing the query to fail and at what point in the query a problem was found. using mysql_error() has been suggested multiple times in this thread to find the cause of the problem. if you are not going to follow the advice given, it's going to take you a very long time to solve this.
  21. after the first suggested change to the sql statement (second line in post/reply #3), all the different sql statements have been equivalent and if they aren't working, means something else is wrong that is causing the query to fail, such as the connection, selected database, table/column names... the only sure and quick way (you should always have error checking logic in your code, it's not just for debugging when you have a problem) is to test if the query returned a result set or a false value and then use the suggested mysql_error() statement to find out why it is failing.
  22. you need to remove all the @ error suppressors from the code and set php's error_reporting to E_ALL and display_errors to ON so that any php detected errors will be displayed. you should also temporarily comment out the header() statements if you are trying to display the images in the browser (so that you can see any php error messages) and remove the header() statements if your goal is to save the images to files.
  23. if someone is getting logged out due to normal/likely user actions, that indicates you have a problem in your code. putting a band-aid over the tail-end of the problem isn't going to fix it. your first step would be to find out exactly what is causing the logout to occur. and based on your thread started after this one, your symptom of the login panel reappearing is likely the symptom of the logout state. fix the problem in this thread, and the other problem will likely go-away.
  24. yes, you have an error somewhere in your code. it would take seeing your code that reproduces the problem in order to narrow down the possibilities.
×
×
  • 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.