Jump to content

mds1256

Members
  • Posts

    259
  • Joined

  • Last visited

Posts posted by mds1256

  1. Nope, still doesnt work.

     

    I am wanting to substitute the field name not a value, so for example:

     

    call sp_selectNewsArticles('fieldNameHERE')
    

     

    would actually run the following SQL:

     

    select id, newsTitle from tbl_newsArticles order by fieldNameHERE desc;
    

     

     

    Try this:

    DELIMITER //
    DROP PROCEDURE IF EXISTS `sp_selectNewsArticles`;
    CREATE PROCEDURE `sp_selectNewsArticles`(IN `fld` VARCHAR(255))
    BEGIN
    SELECT `id`, `newsTitle` FROM `tbl_newsArticles` WHERE `col_name` = `fld` ORDER BY fld DESC;
    END //
    DELIMITER ; 
    

     

    P.S Just add a WHERE clause , I don't know your database structure

  2. Don't think this is what I want to achieve

     

    I want the dynamic part (the IN parameter) to replace the fld field in the SQL code, the table will stay the same

     

     

     

    Okay, drop down your old stored procedure and create a new.

    You need to define a table_name, not column's name.

    Try this:

    DELIMITER //
    DROP PROCEDURE IF EXISTS `sp_selectNewsArticles`;
    CREATE PROCEDURE `sp_selectNewsArticles`(IN `tbl_newsArticles` VARCHAR(255))
    BEGIN
    SELECT `id`, `newsTitle` FROM `tbl_newsArticles` ORDER BY fld DESC;
    END //
    DELIMITER ; 
    

  3. Can you post out your procedure code ?

     

    example code that doesnt seem to work

     

    -- --------------------------------------------------------------------------------
    -- Routine DDL
    -- Note: comments before and after the routine body will not be stored by the server
    -- --------------------------------------------------------------------------------
    DELIMITER $$
    
    CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_selectNewsArticles`(IN fld VARCHAR(255))
    BEGIN
    select id, newsTitle from tbl_newsArticles order by fld desc;
    END
    

     

    call sp_selectNewsArticles('id');
    

  4. Hi

     

    is there a way to use the LIMIT keyword but return all rows.

     

    I am wanting to build a dynamic stored procedure that allows you to pass in a parameter to limit rows if you want to.

     

    e.g.

     

    select * from users limit **            ----- where ** could be a number or all

     

    I can get it to work with a number but If I want all rows what would I put in place of the **'s

  5. Hi

     

    Struggling with the following:

     

    I am wanting to build a dynamic stored procedure to allow you to pass in parameters for the order by column

     

    e.g.

     

    select * from users order by id desc

     

    I want to use the ID part as a parameter so I would call as follows:

     

    call selectUsers('id')

     

    but when I do that it doesnt apply the descending sort... I am sure I am missing something.

     

    Can any one help me with this one?

     

    Thanks

  6. Hi

     

    I have an input button which has a background image, I have set the color to #FFFFFF so the text value of the button is white and set the bacground color to transparent (if i put inherit it is putting a white background on the button and since the button has rounded corners you can see the white on the corners)

     

    No I know they are only warnings but I want to try and get it free of warnings, (i have whole site built with this being the only warning).

     

    What way can I change the css to get rid of the no background / transparent warning.

     

    I tried setting a background color of transparent on its parent (which is a DIV) and then then trying to inherit but it still comes out as white.

     

     

    example of code

     

    <div id="formWrapper">
       <form name="nameHere" method="post" action="">
       .......... more fields here ............
          <div id="formBottomWrapper">
             <input type="submit" class="button" name="submitButton" id="submitButton">
          </div>
       </form>
    </div>
    

  7. for one thing, it's commented out...

    secondly, you need to do:

    if($condition){
         //code
    }else{
         //code
    }

     

    Don't mix using brackets with not using them. Even if you do syntax with no brackets, the code has to be on the next line under the if and else.

     

    sorry the above is not the exact code and it s mixture of pseudo code and php...

  8. I have a div on my webpage that will contain an error message, basically 'username or password incorrect.'

     

    At the moment on the login page I have the div containing:

     

    <div id="errorMessage"><?php echo $errorMessage; ?></div>
    

     

    and in the php code i have:

     

    $errorMessage = "";
    
    if(isset($_POST['username']))
    {
          // check if username and password exists
         // else $errorMessage = "username or password incorrect";
    }
    
    

     

    but unfortunately this doesn't seem to show on the page, any ideas?

  9. Add the code to the myprofile.php page, just before the include header.

     

    Good idea, never even thought of that!

     

    Although I start the session in the header file, is it ok to call session start twice?

     

    E.g.

     

    
    Session start
          If session-isloggedin = false
                   header redirect to login page
          End if
    
    Include header (which also includes session start)
    
    

     

    From the pseudo code above is that ok or is there a better way!

     

     

    Thanks

     

     

  10. I will explain my scenario and if anyone can give me an idea on how to accomplish it that would be great.

     

    I have included a header file which contains my html meta tags and banner.

     

    I then have a footer file which contains my end html tags and my site's footer.

     

    Then I have the individual pages e.g. contact us, home, etc and I include the header and footer file within these documents so I only need to edit the header / footer in one location.

     

    My dilemma is that on one of my pages (myprofile page) I want it to check if I have logged in first, if not then re-direct to the login page.

     

    But when checking for my session variable (isLoggedIn) which is turned from false to true when user has successfully logged in and then using header location to redirect to a login page if it is not equal to true it returns that headers are already sent (which I know as the html from my header has already been loaded).

     

    Now the first thing I thought about was to check this in the header but when browsing the home page I dont want users having to login before viewing the home page or contact us page.

     

    Any idea on how I can achieve this?

     

    Thanks

  11. After you have logged in, the sensitive information is now the session id that you are sending from the client to the server on every http request. If someone 'was' monitoring the data packets (which is why you would be using SSL in the first place), such as over an unencrypted wifi connection, they would have the session id and can visit the site as you and do anything you can do after you have logged in. Since they already have access to the same network you are using, they will also have the same IP that you have when they visit the site.

     

    Have kind of thought about that one and I regenerage the session ID after so many page requests to get a new ID.

     

     

     

    So on another note what is the best way to divert my site to https if a http is entered, I am using IIS for this, is there an easy way of doing this that will prevent users from visiting the http version.

  12. Hi

     

    I am developing a system that users can log into.

     

    Couple of questions:

     

    1. Should I use SSL for when users submit the login form e.g. post to https just for login?

     

    2. Is putting the https address in the form action enough to encrypt the login details or does the page that you are entering the details on (e.g. the login form webpage) also need to be encrypted?

     

    Thanks

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