mds1256
-
Posts
259 -
Joined
-
Last visited
Posts posted by mds1256
-
-
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
-
Not according to this
http://www.mysqltutorial.org/stored-procedures-parameters.aspx
It should be a temp parameter name which can then be used in the procedure.
-
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 ;
-
4000000000
why that number?
-
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');
-
Why it this an SP to begin with/
because the same query is used in many places within the site.
-
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
-
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
-
Thanks very much for the comments, very helpful
-
With the new EU law what is the done way to disable cookies dynamically.
Give the user the option to opt out but how does this work behind the scenes??
Is it Javascript or PHP, and how is it implemented?
-
I sorted this, I basically put the background-color:inherit; before the background:url etc and that worked
-
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>
-
I have just decided to store a true / false value in a session variable and use this to decide if the username or password is incorrect.
seems to work.
-
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...
-
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?
-
I have now sorted this by reorganising my code.
Thanks for the response above it helped a lot
-
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
-
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
-
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.
-
Look at any of the big sites. Facebook, Twitter they all use https for all pages.
They also have huge farms of powerful servers lol, but yes I take your point.
-
IMO you should use https on *all* pages.
But doesnt that increase server load?
And really the only sensitive information is the username and password being posted in clear text.
-
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
-
sorted it, just had to unpick it all, no easy way
-
I have a windows VPS and it comes with PLESK installed and the vps provider doesnt do an image without a plesk install.
I basically just want to uninstall plesk and start from scratch, I followed the instructions from the Parallels website to uninstall and this kind of worked but left config lying about in IIS.
Any quick way to do this?
Stored Procedure - passing in order by parameter
in MySQL Help
Posted
the query should be:
select id, newsTitle from tbl_newsArticles order by id desc