Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. well that isnt an upload script.. just seems to be some variables you are defining, but in the upload script you simply set the name of the uploaded file as th current time stamp, which can be gotten via the time() function. so for example $filename = time(); //proceed with move_uploaded_file() function, using the filename above //in your case, you probably have a directory included in the file name //so it may be something like $filename = "x!/".time();
  2. include/require statements and their derivatives uses file paths, not URLs, to find the page you are including. You need to supply either an absolute or relative file path to the file you want. Assuming the page with the code you posted is in the main directory, (IE if its called page.php, you can get to it by going to xxx.com/page.php), the correct relative path would b "protected/protected_info.php"
  3. jcbones explained it very well, but in the future you should probably post the code you are trying to use that is giving you trouble. Also, doing a little research on the proper technique to use is always a good way to get an answer. In your case, simply searching "mysql timestamp tutorial" or something like that would have probably yielded some useful results
  4. You could do a few things. One thing is you could use the current timestamp as the image name. That would make duplicates almost impossible. You could also take an MD5 hash of the file name, though you could run into the same file names unless you use a unique salt with every hash. You could easily just use a randomized string, or the current time stamp as the salt. Of course if you can do MD5, you can also use Sha1 or any other hashing or encrypting technique.
  5. code?
  6. Mysql joins aren't my strong point, but try using the group by command here is a tutorial on its use: http://www.tizag.com/mysqlTutorial/mysqlgroupby.php
  7. You aren't correctly ending your string with heredoc syntax. read this page: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc it shows how to correctly implement heredoc
  8. Finding something to do isn't really a standard practice. What interests you? Try making a website about it. Once you have a basic layout in HTML/CSS complete, think about how you can make it more dynamic with PHP. Try implementing a user login/register system. Then build from there.
  9. Are you sure your database is populated with data? Is there a mysql error?
  10. No problem. I''m going to mark your topic solved. Edit: you got to it before me. good.
  11. You are missing the closing bracket (the } character) for your while loop
  12. There are a couple ways to accomplish this. The easiest way I can think of (but perhaps not the most efficient) would be to keep an array of all the message ids from the first loop, and then during the second loop before you output, check to make sure the msg_id isnt in the array you compiled in the first loop. So for example, using your queries $msg_ids = array();//empty array to keep track of msg_ids $sqlm="SELECT * FROM msgs WHERE to_id='$id' AND newflag='1' ORDER BY newflag DESC, auto_id DESC "; $rsm=mysql_query($sqlm); while($rowm=mysql_fetch_array($rsm)){ //Shows the rows of messages sent to the user that are new (newflag set to 1). //also keep track of the ids $msg_ids[] = $rowm['msg_id'];//replace msg_id with whatever the column name is } //second loop: $sql="SELECT * FROM msgs WHERE to_id='$id' group by msg_id ORDER BY auto_id DESC "; $rs=mysql_query($sql); while($row=mysql_fetch_array($rs)){ //Shows the rows of messages that have been read by the user and don't have any new messages. //however, we need to make sure that the msg_id hasnt been shown above from first loop. // a simple if statement will suffice $id = $row['msg_id'];//replace msg_id with whatever the column name is if (!in_array($id, $msg_ids)){ //now we know that it msg_id isn't one shown above //however you handle output can safely be run here } }//end while A more efficient way would also include keeping track of previously gotten msg_ids with the array like we did with the first loop, but in the second loop, instead of grabbing all the rows and filtering via in_array(), you could use the array to build a WHERE clause in the query to filter. This would result in less rows being grabbed by your query and less iterations of the second while loop
  13. Your query seems ok-ish to me, though someone could use javascript to change the values of your checkboxes to inject mysql. This would probably break your script at the least, and is a vulnerability. You say it works? As far as nicer or more professional way instead of what you do: You could change the values of the options to being something like "0-100" (for the "To 100 m2" option), and use that dash as the delimiter to explode the string. so for example $range = $_POST['nekretnina_povrsina'];//lets pretend this is 0-100 for the example //now we can split it via explode $pieces = explode('-', $range);//now we have an array that should have pieces[0]=0 and pieces[1]=100 //however, we cant guarantee that the input will always be valid and safe. so lets sanitize it //first we need to make sure that the length of our array is exactly 2 //this will show us that at least the value is of the format xxx-xxx, where xxx is something (hopefully a number) //we will use the count function to do this if (count($pieces) == 2){ //now we need to make sure the pieces are valid. to do this we will convert the values into integers //by using the inval function $low = intval($pieces[0]); $high = intval($pieces[1]); //now we can construct out query $query = "SELECT * FROM nekretnine_ponuda WHERE nekretnina_cijena_ukupno <= $nekretnina_cijena_ukupno AND nekretnina_povrsina BETWEEN $low AND $high ORDER BY nekretnina_id DESC"; //and lets perform our query $result = mysql_query($query); //do the rest } else { //if we are here, it means that the $_POST data was invalid or tampered with some how //we should handle the error gracefully. however you handle errors Don't forget to change the values of the options. For example, the first one would go from <option value="BETWEEN 0 AND 100">to 100 m2</option> to <option value="0-100">to 100 m2</option> Hope this helps
  14. What format does that date come in? You can use the php's date function to compare the current date to the date you get from above. check out the date function here: http://php.net/manual/en/function.date.php without knowing the format your function returns though, it would be difficult to give a code example
  15. OK?... You've told us that your form is outputting something, and post4d some code (code which I don't see how it would output what you have posted) without indicating why this is wrong, and what you expect it to happen. you need to give more information. What did you do to get this response from your code. What do you expect to happen? Where is the code that produces this error? Please give more information, and in the future please be mindful of how you are asking questions. You can't just say "This isn't working", post some code, and expect to get an answer without telling us the circumstances in which this error was produced
  16. Bahahahah gotta love that. Sadly, thats not the worse tattoo I've ever seen
  17. Personally, I've never seen the programming profession as one that would lead to fame at all. Of course, there are those in every field who become famous because of whatever you do (see posts above with names)
  18. mikesta707

    Google+

    Seems pretty awesome. I am interested in seeing what kind of API they build for integrating google+ functionality on other sites (Like Facebook's API). If you have an extra invite though, I would like to try it out.
  19. thats not what I told you to do if (isset ($_POST['Submit'])) { $email = $_POST['email']; $password = $_POST['password']; $confirmpasswrod = $_POST['confirmpassword']; $date = date("y-m-d"); } else { there should be no else here. The code in the else block is what you want to run if the isset() condition is true. all the register code should be inside the if statement block with the (isset($_POST['submit']) condition. The HTML Form is what should go in the else block per my example
  20. There are quite a few problems. One (which your errors point out) is that you never check to see if the form has been sent before you start accessing $_POST variables. Since you have the form submitting to itself, you need to check that the form was submit (Note: You should always check that the form was submit before you continue processing, but its crucial in forms that submit to the same page the form is on). The most common way to check this is to check if the submit button has a value. First thing we must do it give the submit button a name and value in the form. You give your form the name submit and value register. We can check these by using isset(). Once we check it, we are safe to go ahead with the register code. However, if its not set, then we should display the form. This will result in the first visit to this page (to fill out the form) showing the form itself, without executing the register code (doesn't make sense to try to register them if they haven't even entered the information). then once they submit the form, it will execute the register code, and display any errors or a success message. if (isset($_POST['submit'])){ //now we are safe to continue with the register //here is where you should put your register code including the following $email = $_POST['email']; //etc... } else { //now we know they havent submit the form, so we should display the form ?> <form> ..html for form here ... </form> <?php }//this is the closing bracket for our else statement above ?> the last error is talking about the if($submit) code. I think you were attempting to do something akin to what I did above, but got it all wrong. At that point in the code, there is no variable $submit. What happens is PHP makes this variable on the fly, and gives it a value of NULL, which will convert to boolean false when cast (which happens when you use it as the condition for the if statement). Try following the example I provided above, and remove this if statement, and that error should go away also By the way, those "errors" (I referred to them as errors above, but incorrectly so) are actually notices. Notices don't end the execution on your PHP code, unlike errors which do. They are similar, but very different in that respect, and thus the code may act different if there is a notice (which usually indicate that there is something that is bad programming wise, but doesn't break the script) versus if there is an error (something that basically forces the PHP interpreter into a state in which it cannot contiue execution).
  21. One way would be to use PHP's Curl library. Here is an introductory Tutorial: http://phpsense.com/php/php-curl-functions.html Here is a topic about logging into gmail via Curl: http://stackoverflow.com/questions/4748166/how-to-login-to-gmail-through-with-curl the link that topic points to about using curl and the command line to check your gmail emails: http://www.commandlinefu.com/commands/view/3380/check-your-unread-gmail-from-the-command-line I'm not familiar with the process myself, so I cannot give you any concrete code examples.
  22. Well for one you will need to do this with AJAX. If you want to build it from scratch, and you don't know javascript/ajax or even Jquery than you will have to learn that first. However, if you do a google search for AJAX autocompleter or AJAX autosuggester you will probably find some libraries that will suit your needs. Personally, I would probably use some sort of Jquery library or add-on.
  23. That means you are missing an ending </html> tag which should be at the end of your script
  24. Thats a different error from your first one. Notice In your OP, the element type was "script". It seems you have a bunch of meta tags that are unclosed too. Now they seem fine to me for most normal pages, but the XML parser you are uploading or whatever that file to may only accept strict xhtml. so you may have to use self closing tag syntax. Self closing syntax is akin to the following <img src="someImage.jpg" /> notice the forward slash before the closing >. For your code, there seem to be many meta tags missing this. The first one should look like <meta property="og:title" content="[TEXT]" /> I can't really guarantee this will work because I haven't really looked through the rest of your code. You may have invalid HTML elsewhere. The error messages are pretty descriptive though.
×
×
  • 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.