Jump to content

krillz

Advanced Member
  • Posts

    150
  • Joined

  • Last visited

Everything posted by krillz

  1. just a simple question regarding: function db_conn() { $this->conn = mysql_connect($this->host, $this->user, $this->password) or die("Could Not Connect to Database"); mysql_select_db($this->db); } wouldn't using php's "new" OOP mysqli function be a lot better, quicker, and more optimised way of going about creating a connection you can reach using an object method? the mysqli package already offers what you did there. private $conn = new mysqli('host', 'username', 'pass', 'database'); private $result = $conn->query("This is a query I want to use"); also using var declaration is not good coding practise and use proper OOP declaration of variables, public, protected or private, as var many times give you false impressions that the var variables are somehow not reachable, but in fact they are public and can be accessed by any one with the oppertunity to inject code to your application. And about the loop, there is nothing special about the loop, it's just an ordinary loop that happens to be located in a class' method. If you check the info about the fetch_array method it says: So you will need to run it with the MYSQL_ASSOC value, and then you might ask why bother when there already is a mysql_fetch_assoc() function done?
  2. based on the code I would say php generates an error based on this strange code formulation: $audio = $_FILES["audio"]; As there is no such thing. His correct super global array element for the file would be $_FILES['audio']['tmp_name'] but it is deleted as soon as the script hits the end as he didn't move it out of the temporary directory. His form need revising as well, as that is not a correct file upload form, the server never knows a file is coming so even if he changes the code to use the correct array form it will still not find the file.
  3. If you read the post above, where I've shown you how you need to go about uploading a file then you would see that your form is wrong, also how you deal with the files (that is if the server ever knew you were sending something) is not correct. Either check my previous post or check the numerous links provided.
  4. Try dreamweaver and make up your own desicion, anyway the first part of your text sounds like spam, promoting are we?
  5. old news, they check the content, and use keywords from there. That's why it's important to have good SEO urls e.g myurl.com/apples-are-green/ should have a content which is rich on the words apples and green, then you have a good optimized URL and content SEO wise. So key is have content that matches the urls. And do not use shitty non SEO urls like q=12391238&b?sadsad as that hurts you more than ever.
  6. krillz

    SEO Question

    I think he is reffering to masking where URL's lead. Like most affiliate people seeing a refferer number in a link may lead to people not clicking it and just going to like amazon and search for it, then buy it that way. so instead of amazon.com/refferer=210310239 you get myurl/outboud/2/ or something.
  7. I'd invest in a book covering the process of webapplication with PHP+mySQL or go and take some classes if I were you. Just hearing you saying client and not knowing these basic steps gives me chills. Have you informed your client that you are a beginner when it comes to this? Have you any ideas how vulnerable your code can be if you do not have any experience with online security and are creating code accepting user input? Last thing anyone wants is a big disaster that could very well lead to the client sueing you or spread unwanted publicity that will haunt you for years. The second outcome would be the best thing to happen in that case.
  8. alright giving the info you have provided, this upload will only be used by authorized personell in a closed area. I'll give you a quick walk through how you could write your php code to work with mp3 uploads. Let's begin with creating the form one can use to locate and choose what file to upload: > Upload Test Simpel upload form </pre> <form enctype="multipart/form-data" action="upload.php" method="POST"> Upload this file: </form> <br><br><br Right from the start you can see that this form might differ from what you've come in contact with before depending on what you've coded so far. Let's cover some key part of the form that you should know about. The form uses POST, it won't work with GET. Although the PUT method is supported by Netscape composer and Amaya it will not work with the code ahead. In the form tag you have to put the attribute enctype="multipart/form-data". Simply because we have to tell the server that a file is coming along with the regular form information. We also must have a field that sets the maximum allowed upload file size in bytes present. It's of type hidden thus won't show up other than in the sourcecode. However just because it's hidden doesn't mean it's safe so we will be checking it's state further ahead in the coding. In the example above I have around 10,000,000 bytes which very roughly translated somewhere around 10 MB. Remember that the max file size allowed is set in the php.ini file so if it only states 2 MB then our 10MB limit in the code won't matter as the 2MB set in the php.ini is in effect. Lastly we need a input of type file, which is quite obvious, for how else are we supposed to locate the file needed to be uploaded. Also keep in mind to use "normal" names for the inputs, as we will be using them in the php code. so right now we got the html form, we have selected a file and hit upload. Now it's time to process it. So the data we need to handle in our php script will be stored in the superglobal array $_FILES. as our form element is called userfile, the array will have the following contents: $_FILES['userfile']['tmp_name'] is the place where the file has been temporarily stored on the web server, and the copy in this location will be removed from the server once the script reaches the end. $_FILES['userfile']['name'] is just the file's name on the user's system. $_FILES['userfile']['size'] is the size of the file in bytes $_FILES['userfile']['type'] is the MIME type of the file. for example a txt file has text/plain, and a gif image has image/gif $_FILES['userfile']['error'] here any possible error message from an error during the file upload will be located. Good so let's get coding: Uploading file.... if ($_FILES['userfile']['error'] > 0){ echo 'Problem: '; switch($_FILES['userfile']['error']){ case 1: echo 'File exceeded upload_max_filesize'; break; case 2: echo 'File exceeded max_file_size'; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded'; break; } exit; } // Let's check if the file is of the right type (checking MIME type) // mp3 files are of MIME types audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg // I'll be just checking one of them as after all it's way too easy to cheat. if($_FILES['userfile']['type'] != 'audio/mpeg'){ echo ' Problem: file is not mp3!'; exit; } // let's check whether the hidden input field has been altered by some idiot trying to upload // something bigger than allowed if($_FILES['userfile']['size'] > 10485760 ){ echo 'Problem: the file size is too big, do not mess with my html punk!'; exit; } // now let's proceede with moving the file where we want it to be // $uploadFile is the path to where I'll be moving my file, just remember that I'm writing this on a *nix system. // in the root tree I've created a directory called /uploads and it's to here I'm uploading. //So remember full path must be specified. Let's assume you are on a win and want to upload to C:\uploads\ then the path would be 'file://C:/uploads/'.$_FILES['userfile']['name']; // Remember that the directory must exist as well. $uploadFile = '/uploads/'.$_FILES['userfile']['name']; if (is_uploaded_file($_FILES['userfile']['tmp_name']) ){ if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)){ echo 'Problem: Moving file failed!'; exit; } } else { echo 'Problem: Possible file upload attack. Filename: '; echo $_FILES['userfile']['name']; exit; } echo 'File uploaded without any problems'; // Place some code that saves $uploadfile (the path to the file along with all other info you needed in the database after this and you are done. ?> Quite a nice little chunk of code just to upload a file, however as you most likely have spotted, the majority of the code is to check for errors and reporting them back. And I'll cover that in a bit. First let's go through some common sense security aspects of file uploading, although it's a great tool to use, it also is the type of function mostly attacked and abused by idiots trying to harm you and your business. And file uploads with php has a bad history as it had some very nasty security flaws that lead to some spectacular attacks in the past. However they got fixed but nevertheless always make sure you have the latest php version and if you don't make sure you check regularly for patches related to PHP's upload functions. To prevent the case where an old security flaw is present in your system just because you never patched the bad code PHP uses. Also it's wise to restrict the upload system to only administarators maybe moderators depending on the organisation, in other words only trusted people, to prevent any security breaches. Keep in mind if you are not uploading the files to a sandbox/virtual space then a well crafted exploit could reveal you password for accessing the host system, not to mention give free passage to exploring your system and whatnot. So with this in mind let's go over what the hell we just did in the upload.php code. So the first chunk of code is just checking the error code, if one of them occured it will be caught by the switch system, displaying our error code then terminating the script. We then proceede with checking the MIME type. So we check if $_FILES['userinput']['type'] holds that type. It is very important that you realize that this is just error checking and has nothing to do with the security. As the MIME type found in that array element is based on the file ending of the file you are uploading which the browser you are using picks up and send to the server. NO WHERE is it guaranteed that the file being sent is actually a mp3 file and not some script that will cause you a lot of harm. The one that would be interested in spoofing or pretend another file is a mp3 by altering the file extension, has only one reason and this is a malicious intention. Thus the importance of only trusted parties using this system. Next step is a security step, where we check if the file that is said to be uploaded was really uploaded, this is vital as not doing this could result in me sending in a entry to local files on your system, the file exists but it's nothing I uploaded myself, well imagine I just sent in a entry that would result in trying to open or read the file /etc/passwd on a *nix system. That would not be good, would it? if this all goes well, the file is then copied to the directory /uploads/. All you got to do is add a small snippet of code that adds the data of the variable $uploadFile (which is the path to the mp3 file) to you database record and you are done.
  9. Doesn't UTF-8 cover most symbols in the world? Check whether UTF-8 would cover the symbols needed to display all those languages. If so they you would only need one page.
  10. No one can answer what you need, choose the stuff you feel comfortable working with, and it will work. Just because I use something doesn't mean that you will be operating at optimal speed and creativity on the same setup. I pretty sure you've been in contact with computers, laptops, operating systems, applications before, and from your experience you have developed a taste of what you like more and what you like less. You have the answers, and for the ones you don't, get hold of demos and trial versions so you can build your own opinion, and then choose what you liked using the most.
  11. You should know enough of everything that enables you to add the rest of the framework. If we take a proffesional project you will have different groups doing different things and depending on what your job entitles, the answer can be both yes or no. But remember the more skills you have the more you will be used. Let's assume you get hired and you are developing some kind of new service first of a kind. You'll have Coders [programmers, SQL gurus, etc etc] Mathematicians [ algoritms, optimizations ] Interaction designers [ coducting tests to determine the best user-friendly and what a user wants way to display the graphic interface] Designers [ getting the data from the interaction designers and producing the graphical interface] Testers [ testing parts of or the whole products to ensure it meets the goals ] And all will be doing their stuff, and at the end you reach the point where the design needs to meet the code. Design stuff is given to the coders who then incoperate it to the framework as they have a clearer picture of how all works. But in web business it's not uncommon for this task to be left with the designers. If you're lucky the framework is well coded and adding it is just a matter of adding a few lines here and there. But if your unlucky then it can take a lot effort to incoperating the design. To sum this up; Yes you should have enough knowledge so you without any problems could add your design to the existing codebase. Especially if you have a small business as the clients will expect you to not only create the design, but also adding it to their CMS of choice. A way of doing this is to hire a coder to your team, or learn and do it yourself.
  12. what's up with the colons at the name? name:="comments" skip those and it will work, name="comments" The data from the textarea will then be stored in $_POST['comments'] and you can access it through $_REQUEST['comments'] as well as you just tried.
  13. It will take some time for the DNS to be updated to point to the new place, this is a common problem with host changes. Ask your webguy to give you the direct IP to the new server, so you can access it using the ip until the DNS servers your connection uses are all updated, usually take anything between 24 h to a couple of days.
  14. You seem to have screwed up the query ("SELECT * FROM users WHERE username ='" $username "' AND user_password='" $password "' LIMIT 1"); '" $username "' test this instead: "SELECT * FROM users WHERE username ='$username' AND user_password='$password' LIMIT 1"
  15. krillz

    An array question

    To answer the question why the data array was not declared prior to the loop: There?s no need to declare in advance how big an array is or take any special action to increase its size once you start using it. And PHP supports both numerically-indexed arrays and associative arrays ? that is, arrays that have strings for keys. Thus you can do this with arrays and not with variables.
  16. this is the syntax of a if else statements: if (condition) { //do something } else { // do something else } and this is your last else statement on the page: > }else{ echo '</pre> <form action="register.php" method="post"> Username: Password: </form>';<br so if you check it you will see that you do not have a closing curly bracket in that else statement. Thus the error is generated as the php parser hits the end of the file still looking for it. so adding that would resolve that particular problem. > }else{ echo '</pre> <form action="register.php" method="post"> Username: Password: </form>';<br>
  17. generate a sitemap and upload to the searchengines that offer this functionality. You can do it via google webmaster tools.
  18. well you forgot to close the else statement with a } thus the php parser is looking for that but hits the end of the file and generates the error message you are getting.
  19. first time submited I get the response : Thank you! We will get back to you shortly. Seems to work.
  20. Well call it what you want but at least I'm trying. I noticed I left out the > bracket. weird thing is I get this error if I put it back. Parse error: syntax error' date=' unexpected '.' in /homepages/21/d176117763/htdocs/register.php on line 14 ?php include ('mysql.php'); if (isset ($_POST['submit''])) { $username = mysql_escape_string($_POST['username']); $password = mysql_escape_string(sha1($_POST['password'])); if (!empty ($username) && !empty ($password)) { $sql = mysql_query("INSERT INTO users (user_id, username, user_regdate) . . . . . . . . Values (0,$username,$password,time()"); . . . . echo 'you are now registered!' . } else { . . echo 'you must enter a username and a password!';.. } } else { echo ' Username: Password: '; ?> now i have see below ?php include ('mysql.php'); if (isset ($_POST['submit'])) { $username = mysql_escape_string($_POST['username']); $password = mysql_escape_string(sha1($_POST['password'])); if (!empty ($username) && !empty ($password)) { $sql = mysql_query("INSERT INTO users (user_id, username, user_regdate) Values (0,$username,$password,time()"); echo 'you are now registered!' }else{ echo 'you must enter a username and a password!'; } }else{ echo ' Username: Password: '; ?> and getting "Parse error: syntax error, unexpected '}', expecting ',' or ';' in /homepages/21/d176117763/htdocs/register.php on line 16" it works if i remove the at beginning but displays the code. What i am i doing wrong? i am trying to follow you tube video i posted in beginning of post. as I said: echo 'you are now registered!' is missing a ; at the end.
  21. what's the url to the page on the host you are experiencing this problem, so I can see it myself.
  22. what's up with all the dots in your source code? Anyway check over your code, you for instance have forgotten to close an echo statement: > echo 'you are now registered!'; // you have: echo 'you are now registered!' // Also you can parse that big chunk of html without using php } else { ?> </pre> <form action="register%20php" method="post"> Username: Password: </form> <br><br>}<br>?&gt
  23. well you could create a simple php class that works as you site layout base. Devide that into function for showing header, body, side bar, footer. then simply calling the class functions on each page, which would be a good way of having all code at one place instead of 6. And if you need changes to the layout on any page it's just a matter of inheriting the main class and applying the changes in a child class.
  24. Just tried the code, only error I recieved was $message undefined warning, so I declared it as empy. Can't generate any other errors. The code works if you fill out the email correctly you see the thank you message a long with the other values. And if not you get the incorrect message. So the code works for me.
  25. post the whole code, sounds strange as shit, need to take a look at the whole picture.
×
×
  • Create New...