Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Also - what is this character after the if condition? if ( ! function_exists( 'themezee_enqueue_scripts' ) ): Not correct AFAIK.
  2. Your comment says that your query statement gives error if it fails. But you don't show an error message with simply 'or die()'. Try adding some text to the die and see if it says something. Then add some other echos in the following code to check your progress so you can see how far you are getting and debug your problem. Also - turn on error checking. It will help you debug some other errors. For ex., you have an if statement at the top with a '|' in it, which is not a proper logical connector. ('OR' is usually '||')
  3. You should really read a short book on coding in php. A lot of understanding to be gained there.
  4. 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.
  5. My mistake for assuming (!) that the OP was running his php on a server.
  6. 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.
  7. 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.
  8. Then I'd go to a bookstore and peruse the selections there, rather than buy a pig in a poke from A.
  9. www.tizag.com/phpT/fileupload.php Corrected url - seems to have been condensed in the previous post.
  10. 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
  11. 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.
  12. 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.
  13. Can you show us the error message in its entirety?
  14. 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.
  15. 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.
  16. 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.
  17. Event better idea! Very elegant.
  18. 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?
  19. Upon further review, your original str_replace could include the | character along with the item to be removed: str_replace("|goodbye",""); str_replace("goodbye|","");
  20. 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?
  21. do another str_replace on those chars?
  22. 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
  23. A case statement doesn't use the var name again. Try just "case <5:"
  24. 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.
×
×
  • 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.