Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. everything after the 'die' is malformed code. Try quoting your echo, add a semi too. Add a <br> tag to your output echo so you can read the results.
  2. My mistake for assuming (!) that the OP was running his php on a server.
  3. Maybe I don't understand how you do this either. Can you post the php code that you are using just to grab the jpg from the web page? I'd like to see how it can be done.
  4. Learning php is one thing. Using pdo for your db access is a completely different thing. Together you write data-based apps. PDO is just the piece that accesses the databases. There's a lot more PHP in an application than there is PDO. That's why a book is basically unnecessary. Here's an example of pdo usage: I have this standard script stored outside of my web-accessible server tree: I call it: pdo_db_connect_select.php and include it in all my db-needing scripts. <?php function PDOConnect($sc_dbname,$msg=null,$options=null) { // initialize // PDO requires it to be enabled in php.ini /* add this to the ini file: extension=pdo.so extension=pdo_sqlite.so extension=sqlite.so extension=pdo_mysql.so */ // Connect to mysql using pdo api $host="mysql:host=(your hostname);dbname=$sc_dbname"; $uid = "(your uid for your database)"; $pswd = "(password)"; Try { $mysql = new PDO($host,$uid,$pswd,$options); } catch (PDOException $e) { if ($msg == "ShowMsg") echo "Fatal Error<br>Failed to connect to mysql via PDO. PDO Error msg is:<br>".$e->getMessage(); else echo "Fatal Error<br>Possible bad dbname?<br>Failed to connect to mysql via PDO. Sensitive error msg may be viewed with additional parm to call to PDOConnect(dbname,'ShowMsg')"; return false; } if (!$mysql) { echo "Failed to connect to mysql via PDO. Error returned is: " . GetPDO_ErrorMsg($mysql); return false; } else return $mysql; } //***************************** function GetPDO_ErrorMsg($pdo,$i = 2) { $pdo_errinfo = $pdo->ErrorInfo(); return $pdo_errinfo[$i]; } (end) I included some extra code to make my life easier - you can eliminate or adopt it. *!*!*!**! As for actually using PDO here is a simple approach. Note - I'm showing you simple query usage, not a prepared query situation. Start with this and graduate later. // database access require(($your_private_path)."pdo_db_connect_select.php"); $pdo = PDOConnect((a dbname)); $q = "select driver_name,driver_season from drivers"; $qrslts = $pdo->query($q); $numrows = $qrslts->rowCount(); echo "Found $numrows records<br>"; if (!$qrslts) { echo "Could not gather driver names - Error msg is: ".GetPDO_ErrorMsg($pdo); exit(); } else { while($row = $qrslts->fetch(PDO::FETCH_ASSOC)) { (your php handling code here } } (end) This code shows you how to include your std. connection code in your script, how to run the query, handle errors (using again, a simple function I added which you don't have to use), and process the results. Again - you are going to get a few posts (lots?) saying you should use prepared queries. For one-shot queries and scripts doing proper input validation, I find prepared queries not necessary, but they do have a use and you will need to move towards learning them later on. Hope this clears up your confusion. Good luck.
  5. Then I'd go to a bookstore and peruse the selections there, rather than buy a pig in a poke from A.
  6. www.tizag.com/phpT/fileupload.php Corrected url - seems to have been condensed in the previous post.
  7. Download usually means "from the server, to the client", or in today's parlance, "from the cloud to your desk". Upload is therefore: from earth/desk to cloud/server. You want to upload a file? File_get_contents simply reads a file that is already on the server. No uploading at all. You want to do some googling on 'html uploading and php'. Your html will have a type='file' input tag wherein the user chooses the file to be uploaded and then your php will move it to a permanent location and assign a name to it and THEN you can use file_get_contents to read it. And none of this is remote since by the time php begins executing the file already is on the server, thus local. Here's a good example of what you need to code up: http://www.tizag.com/phpT/fileupload.php
  8. If you've been using the MySQL extension, switching to pdo is not very hard. The manual lists all the functions and has sufficient examples to get you through the learning process. Save your money and play around for a bit.
  9. AFAIK, you cannot "download" a file using php or js either. Think of the possibilities Malicious scripts placing files on your local pc? I could be wrong, but I believe I've read of this being taboo.
  10. HTH - pls be sure to mark this as answered.
  11. Can you show us the error message in its entirety?
  12. Sorry, but I don't understand in the least what you want to do. Do you have any code to show us that you need help correcting? Otherwise, I don't think anyone here can help you with the description you have provided.
  13. Did you look at the table to see the record you have been updating? Your query is wrong. Wrap the query in double quotes and the values in single ones so that your values are actually included, and not just the text of the variable names.
  14. Has this ever worked for you? The html appears seriously flawed to me. What's with all the closing </div> tags, but no starting ones? And the <label> tags all pointing at the same id? Anyway, to receive the values from multiple checkboxes with the same group, you need to assign your name= attribute to an array. Try: name='items[]' instead. Then process $_POST['item'] as an array of values.
  15. Event better idea! Very elegant.
  16. You are confused with the concept of server response and real-time response. PHP doesn't do realtime response - it's on the server. If you want realtime response, you probably want to use JS or Ajax. But do you really really need a realtime response for mutltiple activities? PHP is probably going to send all your emails in a matter of seconds, so what's the rush on getting a confirmation so fast? If you are executing any kind of a loop to complete a series of tasks, do you really want to interrupt it?
  17. Upon further review, your original str_replace could include the | character along with the item to be removed: str_replace("|goodbye",""); str_replace("goodbye|","");
  18. Can't see anything in your code, so here's my English language version: User selected a company. Your ads are associated with categories. You need to have some value that connects a company to a category and perform a query to locate the category record you want and then pull the url from the query and display it in an <img> tag on your output. Make sense?
  19. do another str_replace on those chars?
  20. change your select * from email as was suggested to: select *,count(email) as num_emails from email. Now you have an additional field in your query results to be displayed in your table. The reason it was failing was because you were re-using the $results var in your count query thus destroying the original query results. If you had done that 2nd query using a diff var you would have been alright, although inefficient
  21. A case statement doesn't use the var name again. Try just "case <5:"
  22. I believe that the case statements can only test simple conditions, not complete statements themselves. You are using function which aren't allowed. This is different behavior than other languages support in switch statements.
  23. It amazes me that with your lack of understanding of English that you can program in any computer language.
  24. First - are you debugging your script in your browser to see if it's throwing errors at you and you aren't catching them?? (In IE, hit F12, click on the Script tab and hit refresh on your actual webpage window.) Second - your English is confusing me. Is your submit button triggering the js function? In other words, are you getting alert boxes at all? Third - You seem to be calling your js function twice - unnecessary. Fourth - your html is over doing it. Why put a <p> inside a <td>? As for your php - you are doing: return true; after every good validation test. So - where are you returning to? If this code is in a function, they you should start with a var set to true: $valid_input = true; (note - put $valid_input in a global statement at the top of the function.) and in each validation (if) test, if the input is in any wrong, set $valid_input to false, and add some text to an error message variable: $errmsg .= "This field is bad<br>"; Note the .= to collect all the error messages. At the end of this function do this: return $valid_input; and check the returned value in your calling statement and display $errmsg when you go output.
  25. You need to develop a file upload html document. Google is your friend. Write something from what you find in you research and if you're then stuck, come back.
×
×
  • 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.