Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Zane

  1. Cisz, you have failed to even mention the exact problem you are having. You pretty much just regurgitated your code out to us and said "It doesn't work." As you can see by the number of replies you surprisingly have already, this community wants to help you, but they cannot do so effectively if you do not ask your question effectively.

     

    Are you positive that your file uploaded correctly? If you are not sure, then check through FTP or whatever means you use to view your files.... if it is there, then you're problem may be that you are giving the wrong path. We need to know things like, your directory structure and whether or not the upload actually works....etcetera... details.

  2. The real solution to your question is the syntax of the mysql_result function. Sure, I agree that you should not nest mysql functions, but your code should still work regardless and I'm not gonng preach to you about "ideal coding practices". The number one step in figuring anything out in PHP is to look at it's very elaborately awesome manual.

     

    You are currently using this code

    mysql_result(mysql_query($query), 0, 0);

    If you were to look at the manual for mysql_result

     

     

    you would realize you should be using this syntax.

     

    mysql_result(mysql_query($query), 0);

    Why? because your query only selects ONE field. There is no point in specifying the third argument when you only have one field. It is optional

     

    If you did want to specify the third argument, it would be easier to use the fieldname

     

    mysql_result(mysql_query($query), 0, "thefieldname");

     

    Theoretically, your use of the function should work, which says "mysql_result, first row, first column".

    I don't have an answer for why that isn't working as expected but I know that using the fieldname will fix it.

  3. I am participating in this question mainly because I too am interested.

     

    I like the idea of having a XML/JSON file created. What I wonder though, what would be the method with the most integrity, etcetera. My idea is that you could create a new JSON file per session. If the user uses the search bar more than one, the JSON file is just overwritten since the file would be named using their session_id(). Then, somehow I would need to delete all of these files systematically. It seems a chrontab could do this the best?.

     

    I am moving this to Application Design btw.

  4. A better idea would be to add the extra view in your SQL update query

    UPDATE videos SET views = views + 1 WHERE .....

     

     

    ...NOTE.. and yes, there is no $view variable in that query. All that query will do is increment the views field by one.

  5. The question has been answered yet the OP has been offended.. there's no point in keeping this thread open. Although I will agree with Jessica in the pointing out of whining. This is the internet, please try not to take people too seriously and as for the others... watch your words when you know damn well it could set someone off and destroy a thread.

  6. Something like this should do the trick.

     

     

    <ul>
    <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 1) ? " class='active'" : "";?> href="page.php?id=1">Lorem Ipsum</a></li>
    <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 2) ? " class='active'" : "";?> href="page.php?id=2">Lorem Ipsum</a></li>
    <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 3) ? " class='active'" : "";?> href="page.php?id=3">Lorem Ipsum</a></li>
    <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 4) ? " class='active'" : "";?> href="page.php?id=4">Lorem Ipsum</a></li>
    </ul>
    

  7. Maybe I'm just reading your question wrong or maybe it is just too early in the morning, but I cannot seem to grasp the logic of what you want to accomplish.

     

    From what I understand, the letter a would represent 10?

    The number 36 would be represented by z?

    Afterthat I get completely lost?

     

    What exactly would 3A represent? or 1A, 1G, etc..

     

    It would help if you could elaborate more on what certain numbers would be represented by.

  8. These seem to be the dumbest arguments since the Obama/Romney campaigns.  Either side claims that their way will change the future and that that of the other side will destroy everything as we know it.  I have yet to read an intelligent opinion on this case.  Furthermore, this argument has came up several times in the past here.  

     

    If no one can come up with a decent "argument" for the pros and cons of OOP, the thread will eventually and inevitably end up in a flame war at which point it will be locked.

     

    Someone put some effort into their arguments, provide some benchmarks, create some graphs, anotate a bibliography.  Do anything other than just sling insults back and forth.

    ----------------------------------------------------------------------------------

    Just for the record and to add my input, I have never used OOP in a professional setting, only in the classroom.  I must say, OOP does have its advantages.  It keeps you from rewriting code, it allows you to use it over and over again, and given the proper nomenclature... Objects serve as a simple way to accomplish something that would normally be rather difficult.

     

    What I do not like about OOP is that it advocates copy and pasting.  When I was in my C# class, the teacher would give us the code to connect to a database.  All of the students heavily relied on Copying and Pasting because throughout the semester we migrated from procedural code in the beginning and converted it into OOP in the end.  I will bet you anything though that none of those students actually know how to connect to a database today without looking through their old flash drives.  We were taught the use of Objects and that the ConnectionObject allowed us to create a connection to the database.  Several other Objects allowed us to retrieve and store that information.  We never had to write this code manually though.  It was provided for us and 99% of the class, including me, could care less how those Connection and Fetching Objects worked since we had them in our own classes and methods.  It wasn't until I started having to debug errors that I realized the fallacy of OOP.  If you simply copy and paste a bunch of code snippets you find out in wherever into a method named something like..  findNearestByZip, then when the code within that method fails you have no idea why.  You are left with the options of tackling it yourself, googling the error, posting in a forum or searching for a new algorithm altogether because you have no idea what you have copied and pasted.

  9. If you plan to carry variables over multiple pages, your best option is to use SESSIONs which were made specifically for that reason. Read up on Sessions in the PHP Manual, they are very easy to use given you read the instructions.

     

     

    Just a quick hint for your future questions.. You will have to store POST or GET data into these SESSIONS. That is how you will accomplish what you are trying to do.

  10. A much better approach to this would be to use an array instead of having a billion ifs and if elses..

     

    if(trim($name) == '') $error[] = '<div class="errormsg">Please enter your name!';
    if(trim($email) == '') $error[] = '<div class="errormsg">Please enter your email address!</div>';
    if(!isEmail($email)) $error[] = '<div class="errormsg">You have enter an invalid e-mail address. Please, try again!</div>';
    if(trim($subject) == '') $error[] = '<div class="errormsg">Please enter a subject!</div>';
    
    //etcetera etcetera..

    Then you can use the implode function in the end to echo them...as well as check for errors.

     

     

    if(count($error) != 0) echo implode("\n", $errors);

    else {

    Execute code for success....

    }

  11. Do not expect to get very much help from this community by attaching the PHP file. Our community is full of people who are weary to download a file from a complete stranger mainly for security breech reasons. That could easily be an executable whose extension is changed.

     

    Especially since you are absolutely new here.

     

    Post the code (within code tags please), and rephrase your question to be more clear

  12. <a href="/reports?next">Next</a>
    

    Unless you are using rewriteMod which I doubt, the above is an invalid URL

    If reports is a folder that contains an index.php file then the url is fine.

     

    All you have to do is check whether $_GET['next'] isset and then code around it. As far as changing a php variable on click, I dont believe that is possible. You would need to store the current month somewhere like in a $_SESSION variable... then use date("M", strotime("+1 month", $_SESSION['curMonth'])) to get the next month

  13. Retrieving the list of images should be one of the first things you do on this page since it is the feature of the page.

     

    The create_imagelist function should return $html... not echo it. Echo the return of the function..... dont echo inside the function.

     

    Try doing that and see what happens. I'm not positive that will indeed fix it... definitely a shot in the dark.

×
×
  • 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.