Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. You really need to read before writing code. You are doing your querying all backwards. The best approach (IMHO): $sql = "my query statement"; $qresults = mysqli_query($link,$sql); while ($row = $qresults->fetch_array() { (handle the contents of this result row) } You have shown two examples of your misunderstanding where you try and process data that you never queried. First you write, second you execute, third you play with the results.
  2. Create a naming convention using the userid (or some token) for all your docs and store them with that token as a prefix to the name. Use a tree of folders that divides them into the various types of files you will expect to host and display. Then when user logs in use their id (or token) and pull together all the files in all those folders using that id as a search argument. Build your user's web page using these items. Fancy touches - make thumbnails for the initial user page display with links around them to take them to a full-size image. I'm sure you can find several good examples file uploading to use - just be sure to get a decent, modern one using adequate security precautions.
  3. You really should learn how to plan your coding to keep the logic (the php stuff) separated from the presentation (the css/html stuff). Your script is too hard to decipher the way it is assembled now. I use functions to display my output. Usually just one but sometimes more than that. In that function I have php vars that display the dynamic data of that page (built in the php section and passed into this display function), but all the static html and css code is there, or is included there. No need for any of this to suddenly appear in the middle of your php code.
  4. I would put the users into a table in a separate db and search that db for the user in the table and use the db name stored in his entry. Search one db and then connect to the one specified
  5. I doubt you will find help for that in the manual. You simply missed a bracket somewhere.
  6. I did so to show the OP his mistake. I also pointed out and asked the question - Why are you doing this - which is what you have also now posted.
  7. Your foreach looks bad. You get a row of 3 fields and then you create an array that will yield this array : array('label' = 'name1,name1,name1','value' = 'name1'),array('label' = 'location1,location1,location1','value'='location1'),array('label'='address1,address1,address1','value'='address1')) for each row in your query results and then you return that. I think you want: while (list($name,$loc,$addr)= mysqli_fetch_array($result, MYSQLI_NUM)) { $data[] = array('name'=$name,'loc'=>$loc,'addr'=>$addr); } Of course all you are doing here is taking one array ($result - although technically it's called a resource) and turning it into another array($data). What's the point of that?
  8. Things that make no sense. 1 - spawn an email child. 2 - click a mailto href 3 - insert.... into a form's textarea field (for what purpose?) How about telling us what you are trying to do?
  9. How about the query statement that retrieved the date? Echo that out first to be sure you are getting what you expect. Of course, as pointed out, using MySQL's DATE_FORMAT function would do all this work for you.
  10. With the amount of re-write you will have to do to switch over to pdo, how can you NOT alter the queries at the same time? You will simply remove the existing values and replace them with the placeholders and then modify the existing 'query()' call to 'execute(array(key=>value,key=>value))'. Of course you have to reference the un-sanitized values but that too should be simple.
  11. A blank page usually indicates an error or two in your script. Be sure that you have php error checking turned on at the beginning of that script so you'll hopefully see something
  12. I do believe you will hear from many here that using pdo's quote() is unnecessary. With PDO you have access to prepared queries which are the preferred way of running queries this century. Read up on them and use them whenever you have to include user-supplied input as part of your query.
  13. Since you have an invalid function call here (rrmdir) I'm guessing that you didn't bother to turn on php error checking. Do So Now. See what other errors you may have. You could also review this and perhaps shorten it up a bit. For example - why do you explode $filename twice? Why do you not assign the path names up front and use them in place of literal paths being used twice?
  14. More importantly - you will have a unique page for each visitor? Really? Or is it just a customized page that is basically the same for all with just some php-generated(?) tweaks to make it more personal? Also - does the url have to be unique for each user (implying again 'unique pages for each user' )?
  15. Why the @ in front of every poster's name? I dont' get it.
  16. I'll try to explain again. Have your home page - or starting page of your appl - set a cookie before outputting the page Simple. Have a link on this page to take the user to the preferences page. Handle it in the current page's script instead of calling the preferences page directly. If the script detects that the preferences link was clicked, have this same script check if your previous cookie exists - if so send a header to redirect you to your preferences page (or however you will handle them). If the cookie does not exist then simply return the user to the same page with a message.
  17. If your most recent post is accurate (meaning the actual code you executed and not a re-type) then you are losing the content-type header. Look at your assignment right after that.
  18. Read up on MySQL and setup a database and tables in your environment. Then read some tutorials on querying and hwo to implement either MYSQLI or PDO as your db interface (Do Not Use MySQL_* functions). Pretty basic stuff - create a connection from php to sql; select the database to be queried; write/prepare a query; execute the query; check the results of the query (true or false) and then loop thru them to output information. Posting data to the db is pretty similar. Writing the php is something you will have to also read some tutorials on too. There are some very good books out there - check out a decent bookstore or library and spend a few hours reading, starting with the basics. Most importantly - be sure you use good practices. Security against hacking and injection are the most important things to keep an eye on - don't short-change yourself by ignoring these things. Again - read. The php.net manual is an important resource to all php programmers - set up a keyboard link to it and keep it uppermost in your mind as you write and need to lookup things. Link to that and other resources can be found at this site/forum's home page. Do yourself another favor by avoiding like the plague big chunks of code that you find by trolling the net. You will most likely download something that is years behind the times, uses inappropriate code and does not handle security and injection properly. Learn. Write. Then ask for help.
  19. 1 - DON"T bury functions inside your main line code. Keep them separate. 2 - You're losing your content-type string from the message body.
  20. You cannot send a header once ANY information of ANY kind (characters,blanks, empty lines, etc.) has been output. The message is telling you EXACTLY what line of your code is sending something. Stop it.
  21. I have never thought about testing - if my cookies don't show up, I default them to blanks and operate with those values. I have to think that setting a test cookie upon startup prior to clicking on the link to open up a preferences selection page would work. If they click to set their preferences, you simply check for the test cookie and if you fail to get it, you direct them to an 'error' page telling them they need cookies. Otherwise you let them set away! Of course if you are going to have a lot of these cookies you might want to think about a db table to contain all the settings.
  22. Change your flow to only upload an image file on new records. Let the user upload the image file first. If the upload is received successfully then prompt the user for the info behind it. To ensure that you don't get a lot of images w/out info, create an image record to track the image name and the date is was uploaded and periodically go thru the image table to look for images that are over a certain age and do not have a true info record in the main table. Basically, you will never have to modify the image once you have it, so just worry about the data after you do.
  23. Or perhaps that you have your default case above most of the other conditions in your switch. The 'default case' should be after all the other possibilities have been checked.
  24. Isn't the whole point of going to a forum such as this to be told what to do? Methinks you have it wrong if you don't want to be told everything you are doing wrong. Is that your complete mastery of the English language? Not much better than your PHP I see.
×
×
  • 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.