Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. Ok, well in that case I would start with your database. How do you want to represent this data in MySQL? What data do you want to store? When searching the database, what information do you think you will be searching on/sorting by? I would then populate the table(s) with some sample data to get you started Afterwards, you can work on the actual meat of the problem. Start with a simple PHP script that will output the list with sample data you populate your table with. From there you can start tying to figure out how to filter the list/sort the list/etc. Having a starting point is the most important thing though. Once you start, you can/should come back here with whatever problems you are having with your code, and we can try our best to help you.
  2. glad you found your problem. If your topic is solved you can click the topic solved button at the bottom of the thread, or simply indicate its solved and I can mark it solved for you.
  3. Well I have no clue how your script works (although using unserialize like that doesn't sit well with me.) It may be because the string is empty, as that is the notice that PHP issues when unserialize encounters and non-unserializable string IIRC. But I don't really know the context that that line is in, nor do I know what the format of the text file will be. You can check if the file is not empty before you do the unserialize, IE $txt = file_get_contents($this->msgsFile); if (!empty($txt)) $contents = unserialize($txt); else $contents = "";
  4. You have your update mysql inside the if statement that is only true if you successfully move the uploaded file. You probably want to put another query (the one that only updates the myfile field or whatever) in the else statement.
  5. The unserialize function takes a string representation of a PHP variable (generally created by its sister function, serialize). You seem to be passing in the contents of a file rather than a serialized string. What are you trying to accomplish here?
  6. When you submit the form, on whatever page that form is submit to you will want to run your validation code. The form data will be in either the $_POST or the $_GET super global (depending on the method you use). You could also use some sort of Javascript/AJAX validation if you want to make validation a little more user friendly. However, always remember to validate on the PHP side because a user can disable javascript and bypass any javascript based validation.
  7. Hmm well array key naming rules don't restrict the use of numbers so I couldn't imagine why that key would be giving you trouble when numeric keys aren't. Try doing print_r on session to see what it has in it. You could also try posting your other relevant code to see if maybe there is an error in something you do with the $_SESSION
  8. Do you have the session_start() statement at some point before that code?
  9. if you want to show sub folders you will have to go through all your directories retrieved from the original glob call, and recursively or iteratively call glob on each of those directories. I would suggest doing this recursively myself. If I remember correctly, in the comments section of the glob manual entry some people have already found the solution to this problem and posted the relevant code.
  10. first, image tags are self closing. They dont have any inner elements. Second, you want to add the image url to the src attribute of an img tag, like so $output .= "<img src='{$row['disp_pic']}' /></br>\n";
  11. Do you have any code? How much PHP do you know? what kind of coding model (if any) are you planning on using? Are you just looking for a nudge in the right direction? I understand you are trying to make some kind of movie list, but i'm not sure what you are asking us to do for you.
  12. Since you are using OR, you need to keep all the OR statements inside 1 group parentheses. Try outputting the whole query as it is right now. once you do that you will probably be able to see where your error is in your code. also, you may want to use a full text search rather than using LIKE. Its faster. read up on it here: http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html
  13. try using the glob() function with the GLOB_ONLYDIR flag. see the manual entry for more information and code examples: http://php.net/manual/en/function.glob.php
  14. Ok? What, do you want us to do it for you? There is a freelance forum if you don't want to do your own work. If you want help thats fine, but at least try to put forth a little bit of effort. This is a volunteer forum. You get out what you put in, and if your not even willing to think then you won't get any help. How do you represent the value of "action" genre? Do you know how to create a query? The fact that what you are asking for is so incredibly simple yet you seem to refuse to put forth any work towards figuring it out makes me think you don't want help, but rather someone to do your work for you.
  15. Ahh I see. Well in your PHP script are you sending back a JSON object, or XML? JSON would be easiest, as you can use PHP's built in json_encode function to have it convert the PHP array into json for you. To get the structure you want, based on what I've read, you will need to have a multidimensional array, or rather an array of associative arrays. You will need to loop through your result set in order to fill the array with all the information from your database. Note, as your database grows, this method will become more and more inefficient, but it doesn't sound like you have the type of numbers in your database that would make a difference. $array = array(); $while($row = mysql_fetch_array($result)){ $name = "$row[LastName], $row[FirstName]"; $id = $row['id']; $array[] = array("id" => $id, "value" =>$name, "info" => ""); } //the json objects needs to be of the strucuture: //*** { results : [ { id: "1", value: "value", info: "some info. can be blank"}, { .... }, { .... } ] ****/ //so we stick the whole thing into another array $jsonArray = array("results"=> $array); //now we can send our json array back in json echo json_encode($jsonArray); hope that helps
  16. Thats about right yes. You probably only want to redirect when you successfully send mail, otherwise the user may be redirected and think their mail was sent when it wasn't. if ((isset($_REQUEST['name']) && $_REQUEST['name'] != '' && isset($_REQUEST['email']) && $_REQUEST['email'] != ''){ if(mail( "info@byrnecomputingservices.ie", "Enquiry from Byrne Computing Services", "$mailcontent", "From: $name <$email>" )) header( "Location: http://www.parkersmedia.com/byrne/thankyou.shtml" ); else echo("Could not send mail"); } Added the if-else around the mail function just in case the mail function fails (which happens sometimes, even if the $_REQUEST info passes the validation).
  17. We don't know what you call your columns/tables/ etc. in MySQL so we won't be able to just give you the query you can copy and replace with. You will need to report a little bit more on your system before we can fully help you. You say you want to search your mysql database based on a constraint. This constraint is on the genre of the movies (action movies if i remember correctly.) So my question to you is do you store the genres of the movie in your table? If so what is this column called that stores the genre? What format is it in (is it a varchar?enum?) if its a string do all action movies have the genre set as "action"? or are they random strings with action as part of them (IE just action, or something like:"sci-fi action adventure!") When you can answer questions like these, we will be able to help you better
  18. Hmm i'm not quite sure what you are asking for. Could you perhaps clarify? Just guessing, but did you want to combine the first and last name into 1 string (to feed into your auto complete form or whatever)? If so, you simply need to concatenate the two values. I don't know your column names, but assuming LastName and FirstName are used, $first = $aUsers['FirstName']; $last = $aUsers['LastName']; $combined = "$last, $first";
  19. No. The problem is you are overwriting your array with the value of its size. As far as PHP is concerned, you no longer have an array, since you changed the reference to it to another piece of data. Its kind of like the size of the array (say, 5) killed the array and stole his identity... What you want to do is change the name of the variable you use to store the size of the array, or use the size of the array directly in the for loop. for example //assuming $filesCount is your array $count = count($filesCount); //now we still have $filesCount for ($i = 0; $i<$count; $i++) { if($filesCount[$i] != null) { ... or //dont change $filesCount for ($i = 0; $i<count($filesCount); $i++) { if($filesCount[$i] != null) {
  20. Well text and images won't be too hard. I am not sure how proficient you are, or what you know, but I would start with learning how to create and manage a MySQL database. A google search will probably turn up some tutorials. Then I would learn about uploading images, and using the MySQL database to allow the user to upload text. Then you may want to try to allow the user to add images inline, perhaps using an open source WYSIWYG editor.
  21. Well, your request is somewhat vague. What kind of lessons are we talking about. If they are just text based lessons (maybe some images here and there), you could create a rather simple site that meets those needs. Some HTML and PHP/MySQL would probably get the job done. But if you wanted something interactive in real time (as in the user doesn't have to reload the page every time they preform an action) that it becomes rather complex. Even more so if you want other users to be able to create and upload their own lessons. This could require some rather difficult coding if you are new to PHP. You would most likely have to learn actionscript, jquery/ajax, or perhaps java, in addition to some fairly complex php coding potentially. This kind of system isn't really something anyone could code up in any decent amount of time without wanting to charge for it. If you truly want to do it yourself, perhaps you should start with a simple design, and add more complexity to it as you learn more.
  22. When creating a function in PHP (and in pretty much any programming language) You have to option of specifying parameters in the argument list (The stuff between the parentheses) that allows you to pass information to the function that is available at the time of the function call. So for example function foo($arg1, $arg2){//the ($arg1, $arg2) part is the argument list echo $arg1 . " is friends with " . $arg2; } //some random amount of code or whatever //... foo("John", "Nick");//output: John is friends with Nick foo("Mike", "Kyle");//output: Mike is friends with Kyle //the names John, Nick, Mike, and Kyle aren't available when we define the function (we don't know the names yet!) //but will be available when you run the script later on, and decide who you say is friends with who //obviously the names are arbitrarily picked in this code, and could be hard coded in the function //but the example illustrates my point well enough I think In the case of your code, the arguments that you may want to pass would be the arrays that you are iterating through (namely $array and $membernumber)
  23. HTML entities has an optional charset argument (the 3rd argument) which you can use to specify a charset for the function to use in its conversion. It seems to me you have a charset problem, so check out the manual entry on htmlentities: http://php.net/manual/en/function.htmlentities.php and look at the examples which specify a charset, and look at the charsets that PHP supports. I am not very knowledgeable on what characters are in what charsets, so this is just a guess, but ISO-8859-15 may be what you need
  24. Yes, unless you use the global keyword, no variables with a script-wide scope will be available in functions. Using global is generally frowned upon however, as it makes the function you created dependent on outside information, which greatly reduces its portability and re-usability. Functions should only be dependent on the information you pass into its argument list. Is there a reason you don't just pass the relevant arrays into the function via the argument list?
  25. You could place that in a couple of places in your code, but the easiest place would probably be to wrap that if statement around your mail(...) statement. IE if (... the if statement provided by buddski ...){ mail(... your arguments here ...); } Also, if you are interested, I wrote a tutorial on validation in PHP, which you can read here: http://blackscorner.me/2011/07/28/when-and-how-to-validate-your-php-variables/ There are actually two parts of that tutorial, the second deals with sanitization: http://blackscorner.me/2011/08/04/when-and-how-to-sanitize-your-php-variables/ They aren't the end all be all of tutorials on this subject, but its a fairly straight forward introduction
×
×
  • 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.