-
Posts
1,041 -
Joined
-
Last visited
-
Days Won
17
Everything posted by gw1500se
-
Generate JSON structure from array of items
gw1500se replied to frontEndCoder's topic in PHP Coding Help
You can use json_encode to do the conversion. It would be easier to restructure your array so it can be json encoded. -
No, you should change the sudoers file to allow user apache to run that command. However, before you get yourself in trouble, please explain why you need web users to run restricted commands. Perhaps we can come up with a safer alternative.
-
While you are playing with fire giving users access to a root command, the sudoers file needs the user running the script. It is probably 'apache'.
-
What does "doesn't seem to work" mean?
-
$_SESSION data is stored on the server. If you run 'phpinfo()' and look for the variable 'session.save_path' you can see exactly where it is. Cookies, on the other hand, are stored on the client.
-
Cards are formatted with CSS so this is not really a PHP question. Perhaps this example is what you are looking for.
-
Did you add a form to enclose your submit button? Show your HTML.
-
Yes, you need to learn form handling.
-
Part of the problem is way you generate your IDs. How do you know that it is the same Jim? For your immediate problem, you don't have the submit button associated with a form. You need to tell PHP what mode you are using (POST or GET).
-
You are confusing me. PHP DOES only execute when the submit button is clicked. What makes you think it gets executed otherwise? Then you need to check for identical IDs. You didn't post your schema so it is difficult to be more specific.
-
Your SQL statements section is where you need to eliminate duplicates. Check to see if the record exists and if it does don't insert it. Perhaps you just do an update instead or let the user know it is an attempt to insert the same data.
-
PHP data matching dropdown with qr code scan
gw1500se replied to Bramhowl's topic in PHP Coding Help
So far you have not explained what pieces of data you want to match. We cannot help you until you make it clear what you are trying to accomplish. You are getting the same thing when you submit because you are processing the same page. Keep in mind that PHP is stateless. That means it does not know what happened the last time it was executed. I see nothing in your code that checks to see if the page is output the first time or output because of a submit. If you want something different to happen on a submit you need to know that button was clicked and do whatever for the submit. I am not sure what submit does when it is not part of a form or has no 'onclick' attribute. -
PHP data matching dropdown with qr code scan
gw1500se replied to Bramhowl's topic in PHP Coding Help
Yes but again you should use the code icon. Now when you run the script you can follow the flow and determine what is going wrong, where. Also make sure you have error reporting turned on. Put this at the top of your script: error_reporting(E_ALL); -
What did you try? What error(s) did you get? What is not working as you expect? Do you expect us to use our clairvoyance to understand your code? When you post your code be sure to use the code icon (<>) and specify PHP or HTML as appropriate.
-
PHP data matching dropdown with qr code scan
gw1500se replied to Bramhowl's topic in PHP Coding Help
'echo' your data throughout the script so you can see what the variables are as the logic progresses. -
PHP data matching dropdown with qr code scan
gw1500se replied to Bramhowl's topic in PHP Coding Help
Start by editing your post and using the code icon (<>) and select PHP for your code. The formatter makes your code much easier to read. Second, tell us what error you are getting on what line or what you expect vs. what you are getting. -
I suggest you are going about it the wrong way. Use DOM instead.
-
You don't show which is line 157 but it is fairly obvious the problem is with $file and the fopen. Make sure you have error reporting turned on at the beginning of your script: ini_set('display_errors',1); error_reporting(E_ALL); A better way to do what you want is: if ($file = fopen("csv3.csv","r")) { echo "<pre>"; print_r(fgetcsv($file)); echo "</pre>"; } else { print("Error opening file: ".error_get_last()); There are several other weird things in your script but this addresses your immediate problem. I'm guessing the error is "file not found" since the file will not be uploaded to the document root. You should be using $_FILES to get the uploaded file.
-
How can i create a bitcoin/e-cash deposit and withdrawal with PHP
gw1500se replied to Blacbizzy's topic in PHP Coding Help
Search engines are you friend. https://www.blockchain.com/api -
I can't but there are others that likely will. Post your request in the Job Offerings forum.
-
You are correct, it doesn't check for required fields. The most user friendly way to do that is with a javascript before the form is submitted. That way the user does not get frustrated when inadvertently missing a field and not knowing it until the server responds after the submit. That being said you should check again in PHP before using the fields in case someone is messing with your form.
-
Nope. Don't make people go to a 3rd party site. This forum is specifically designed for posting code here. Be sure to use the code icon (<> at the top) and select PHP or HTML as appropriate.
-
Since PHP 'strtotime' accepts the string 'weekdays' you don't have to worry about weekends. $delivery=strtotime("5 weekdays"); You then only have to account for holidays.
-
After careful analysis and deliberation of the original post I would tend to agree. 🙂
-
Elapsed Time Does Not Increment by Seconds or Minutes.
gw1500se replied to phreak3r's topic in PHP Coding Help
Keep in mind that PHP is server side and it is stateless. That means when you refresh the page, it is the same as issuing the page the first time unless you use sessions. It is not clear to me exactly what you are trying to accomplish but it perhaps you want to use javascript which is client side.