-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Need help to use .ini file settings to create php code
ginerjm replied to andrey613's topic in PHP Coding Help
I just love when people say "it's not working" because it tells us exactly what to look for when trying to hope you. Can you possibly tell us what is happening? Are you just getting a blank screen? Are you getting error messages? Are you getting any meaningful output or results? Have you tried adding some debugging code to echo out values along each step of the process so you can track how far your code gets before things go south? PS - Please use the suggested forum tags when posting code. Wrap your code in the "code" tags which are the words 'php' and '/php' wrapped in square brackets. Like this: $var = 1; -
Need help to create dynamic php next content page.
ginerjm replied to Rayhan420's topic in PHP Coding Help
Sounds more like you are new to programming in general as well as user forums. This forum is here to help people with their code - not to just hand out snippets of code to solve your problems. When you decide to settle down and teach yourself some stuff and can give us your attempt at a script, then you can ask for help with it. -
how to expire php page after 7 days from page load on server in php ?
ginerjm replied to reutorah's topic in PHP Coding Help
It's not a waste. You got very good advice. You have just chose to ignore it in your anger at being told what was wrong with your design. Don't feel bad - we all make mistakes when starting out. Of course your choice is going to cost you money. I'm pretty sure that your choice of developer is going to also agree with what you have been told here. If you pay him/her enough money he just may do what you want. But then when you eventually see the problems with your design, you'll have to pay him/her to correct it. -
Help on Select data from mysqli using an array in WHERE clause
ginerjm replied to ludah's topic in PHP Coding Help
I'm having a good day! -
Help on Select data from mysqli using an array in WHERE clause
ginerjm replied to ludah's topic in PHP Coding Help
1 - I think you have an extra set of quotes around $array in your array_map call. 2 - Why apply "intval" to array elements that are clearly not numeric? 3 - To use the IN operator in SQL I think you need to explicitly list the array elements. Try doing an explode of the array into a string with a comma inserted as in: $items = implode(',',$array); ... ... where id in ($items) -
To start with - Jacques is giving you extremely good advice. Ignore it at your own peril. Trusting in a secure login is the same thing that all of the big retailers, banks, credit card companies, etc. have been doing for years and look how they make headlines? Through hackers! So - are you going to trust your very bad design behind a security portal that is most likely weak? Secondly - the design of a page with multiple forms that you then want to automatically consolidate is something pretty sophisticated for a newcomer. I suppose you got that from a trusted source also? HTML5 seems to offer the ability to assign input elements to specific forms with certain attributes but I am not sure how that all works now. (Mainly because I have not needed to do that.) If you used a db to store your info you could probably avoid the multi-form concerns that you have just by saving each text box into its own column in your table. Of course as pointed out to you already you have to be sure to sanitize all of your user input data! PS - Trusting in "other people's code" is something to be avoided. Just because it looks great to you (a newbie?) doesn't mean it's so good. Listen to Jacques. He knows of what he speaks.
-
Checkbox Form to Update Multiple Rows in Database
ginerjm replied to MartynLearnsPHP's topic in PHP Coding Help
Nah - too hard to follow. Good luck -
how to expire php page after 7 days from page load on server in php ?
ginerjm replied to reutorah's topic in PHP Coding Help
Sorry. Won't give you code since that is not the focus of this forum. More importantly (as I have been told previously) it is not a good idea to promote "bad code" here, which your goal is to obtain. -
Your logic has several NON-nested if statements. Therefore it will evaluate your first search, then your second, then your third without fail. Also - your use of the ".=" to assign the error messages means they will all accumulate. That explains why you have those messages. Question - you are using a syntax for strpos that is not in the manual. The syntax I see is (string,search_string) yet you are using (string,search_string,search_string). I'm surprised it runs at all.
-
Checkbox Form to Update Multiple Rows in Database
ginerjm replied to MartynLearnsPHP's topic in PHP Coding Help
One thing that would help you and would help us to understand would be to SEPARATE your html form your php. Don't start your php process with a line of html. Do all your "thinking work", make your decisions, build php vars with any dynamic html generated by the conditions and THEN output your html, seeded with php vars where their content needs to go. You'll end up with a script that can be more easily modified and understood. Second - How is this form being submitted? You have no submit button so I can only guess that your onchange event is doing it but you didn't show us that code. PS - why is your form saying it will be POST'ing and yet your php code looks for a GET input? Plus - you don't allow for the user to make a mistake with his mouse since the onchange is going to take off as soon as the user does anything. (Although I don't see another element on your form that would trigger the onchange since you aren't showing anyplace else to go to.) So now - do some alterations to separate the functions of this script (sending out the select code, retrieving the chosen option, doing something with that option, sending out the new results) to help us see what you are doing. Perhaps it will also help you see what is wrong. For one thing it will make it easier to add some debugging code so you can see how your script progresses thru the different stages. And add a submit button! -
how to expire php page after 7 days from page load on server in php ?
ginerjm replied to reutorah's topic in PHP Coding Help
You have already been told many reasons why you can't or shouldn't do this thing. #1 - if you give them your code you're done. They should send you a thank-note before they take your hard work and change it to suit them. (This would be very generous of you!). Do what others here have said. Sign people up for a free trial and record their individual start date and user id. Be sure to store your main code outside of your webtree so they can't steal it and let them play until their time runs out. Put the entry page in the web tree and get their login creds there. Anything else is just not gonna be good for you. -
Splitting a string based on the last instance of a character
ginerjm replied to sn00pers's topic in PHP Coding Help
I think I gave you that solution. Perhaps a little unwieldly, but correct. -
You've lost me. I have no idea what you want. Good luck.
-
If you are doing a click on an anchor it is going to take you off that page. If you want to make an update to the current page WITHOUT leaving it, look into ajax and JS.
-
Splitting a string based on the last instance of a character
ginerjm replied to sn00pers's topic in PHP Coding Help
Hmmm, I must not understand the question. OP wanted two parts - one with the first n pieces and one with just the last piece. That seems to be what his/her example shows. Using the implode to build the first part is a good idea, but you have lost the last part. -
Splitting a string based on the last instance of a character
ginerjm replied to sn00pers's topic in PHP Coding Help
$split_chr = ':'; $parts = explode($split_chr,$source); $sz = count($parts) -1; $part1 = ''; for ($i=0; $i<$sz-1; $i++) $part1 .= $parts[$i]; $part2 = $parts[$sz]; -
To help you figure this out I would point you to the php manual. It says exactly where you should do it. In fact, where you HAVE to do it - "before any output is sent".
-
Commenting out an echo statement causes my code to error 500! HALP!
ginerjm replied to Ciffy's topic in PHP Coding Help
You're trying to echo an array var which is giving you an error - but since you haven't turned on error checking you can't see it. Do as Jacques1 said. -
I agree strongly with Maxxd on the use of $_REQUEST. You KNOW whether it is a post or get so USE that array name. I also agree with the comments on using a fully prepared query, ie, use parms for all of the query's values, not just for a couple of them. This would also help alleviate the injection possibility that you are creating by using un-sanitized input values. Lastly you could read up on how to use single and double quotes and braces for your query string. Consider this: sqlStatment = "UPDATE products SET catid={$_REQUEST['cat']}, cattxt='$catText', ptitle='{$_REQUEST['ptitle']}', saleoffer='{$_REQUEST['saleoffer']}', ... ... WHERE id='{$_REQUEST['pid']}'"; A much simpler statement to construct and to read. Of course when you SWITCH to a properly prepared statement it will be even easier: sqlStatment = "UPDATE products SET catid=:cat, cattxt=:cattext, ptitle=:ptitle, saleoffer=:saleoffer:' ... ... WHERE id=:pid";
-
how to expire php page after 7 days from page load on server in php ?
ginerjm replied to reutorah's topic in PHP Coding Help
I can think of many people NOT wanting to upload any script of yours (or anyone's) to THEIR server. Thatis if they even HAVE a server of their own. I know I wouldn't and it's a good guess that those in the know on this very forum would not do it either. I'm thinking that you have some kind of registration process that would then lead to this "uploading" scheme of yours. Why not use that registration as an access method to the script on your server? When the registration occurs you save the date of it. When that date reaches an age that you wish to expire the user at, mark the user's reg record as expired and do your re-direct thing. You may argue that the registration can be cheated by a user who creates a fictitious second or third userid. Sure that can occur, but so can the process you envision where the user would be uploading the script to their server. -
Return null or array in function if conditions are met
ginerjm replied to jiros1's topic in PHP Coding Help
What do you mean "when you return null it doesn't work"? WHat doesn't work - the return? Or the "print_r" that you are doing? For a solution to the latter simply CHECK the value that is returned before trying to print it. -
Return null or array in function if conditions are met
ginerjm replied to jiros1's topic in PHP Coding Help
It would appear that your script is doing that for you now. But since your output is showing an array apparently your test conditions are producing valid output. Have you tried testing with conditions that would ensure that you won't get any data back? IMHO - wouldn't it be easier to understand/handle if you returned 'false' instead of a null value? -
how to expire php page after 7 days from page load on server in php ?
ginerjm replied to reutorah's topic in PHP Coding Help
Whatever do you mean by "expire a page"? What does that mean to you? A "php page" is merely a script. It sits on the server and does something for you when called. That said, I find your question difficult to comprehend. Do you mean you want the script to no longer run when someone types in its url, as if the script had been deleted from the server? -
Brand New to PHP... AND I haven't coded in a few years... :)
ginerjm replied to Gregan's topic in PHP Coding Help
I tried this once. It ain't that easy! -
Brand New to PHP... AND I haven't coded in a few years... :)
ginerjm replied to Gregan's topic in PHP Coding Help
Don't have a clue as to what you are attempting but... Have you never worked with arrays before? You are supposedly creating an array with a character index value that is the SAME for every entry. What that means is your array will have only one entry - that being the last one you create. Of course your whole syntax looks strange to me so I may be wrong. I'd look at the php manual to see how to create an array format that works for you. The syntax I see mostly (and use) is: $colors[] = "#000000"; $colors[] = "#000001"; Or $colors = array(#000000,#000001,......); These elements would then be referenced with with a foreach as you did or with a for command as in: $maxclrs = count($colors); for($i=0; $i<$maxclrs; $i++) { do something referencing $colors[$i] } Good luck!