StevenOliver
Members-
Posts
237 -
Joined
-
Last visited
-
Days Won
6
StevenOliver last won the day on July 16 2020
StevenOliver had the most liked content!
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
StevenOliver's Achievements
Advanced Member (4/5)
21
Reputation
-
Directory not writeable even though chown and chmod
StevenOliver replied to StevenOliver's topic in Apache HTTP Server
Forget it. Thank you for your time. -
Directory not writeable even though chown and chmod
StevenOliver replied to StevenOliver's topic in Apache HTTP Server
Unfortunately, I have google searched this exact thing, and found too many conflicting "solutions." Each "solution" proposes a line of code, followed by, "well, this worked for me...". And, I don't want to mislearn yet another "hack." Rather, I'd like to know the correct way to do this. So here is a properly worded question: For a sudo user to create files in the /var/www/html directory of an Apache2/Ubuntu 20.04 cofiguration, what are the "best practices" lines of chmod and chown code to accomplish this? Thank you -
Directory not writeable even though chown and chmod
StevenOliver replied to StevenOliver's topic in Apache HTTP Server
But I am a member of the www-group. I thought that was the point of "becoming a member." Would you please explain what is the point of being a member of the www-data group if I do not inherit its privileges? -
Directory not writeable even though chown and chmod
StevenOliver replied to StevenOliver's topic in Apache HTTP Server
755 means: Owner can read, write, execute. Everyone else can read, execute. When I stat my d and f: 755 drwxr-xr-x www-data www-data Aug 5 20:18 www 755 drwxr-xr-x www-data www-data Aug 5 20:19 html 644 -rw-r--r-- www-data www-data Aug 1 18:12 index.html ... and check if I'm a member of www-data.... $ groups //command line My_User_Name sudo www-data // result So, www-data owns the files. And, I'm a member of www-data. As a member of www-data, I should also be able to write. What am I missing? -
Upgrade php to 7.3 I see 7.2 in my browser
StevenOliver replied to mstdmstd's topic in Apache HTTP Server
Unless you really want 7.3, you know there is PHP 7.4 available, right? -
On Ubuntu 20.04, I've done this a hundred times and it's always worked fine: chown -R www-data:www-data /var/www/html usermod -aG www-data My_User_Name Today, when trying to write a file in html, I get a "Directory '.' is not writeable" error. All the directories are 755, all the files are 644, and I've verified I'm a member of www-data. What am I missing, please? Thank you. p.s. I know I can do "chown -R MyUserName:MyUserName /var/www/html" and then I can write to the directory... but I'm trying to figure out why on earth the above suddenly won't work.
-
Barand, thank you. It does look naked without the ( ) though... mac_gyver, sorry I didn't know that.They sure are coming up with newfangled things nowadays!
-
Okay, now you get to do what I've had to do a thousand times.... google your error message, click the first result and see which scenario applies to your script. Debugging goes like this: 1.) Error reporting (you now have that at the top of your page) 2.) Google your errors 3.) Fix your errors. p.s. I'm still bothered about your <form> tag which appears to have no action ... but I'm too lazy to read your code and see if you have a javascript form.submit() in there somewhere... p.s#2 ..and the line of code that reads: if(isset($_COOKIE["id"])) .... where is "id" anywhere on what you posted? I see a setcookie("user_id" ..... and obviously "id" is different than "user_id" so does that need fixin' ???
-
How do you enforce no trailing slash, on homepage only?
StevenOliver replied to simona6's topic in Regex Help
...it took me years to realize the best websites -- the ones on "page one of google" -- almost universally break every "SEO" rule, have the worst, most improperly formatted html, duplicate content, errors up the wazoo.... heck, if it were me, nowadays, and I wanted to be on page one of google, I would intentionally violate every SEO rule. Go ahead, check it out.... look at the top sites on google, NONE of them follow any rules! Then.... go to page 50 on google, and you'll find all the perfect "no errors" websites, with perfect un-duplicated titles, perfect html, pure as the driven snow. Page 50. -
1.) Put this at the top of your page: <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ?> 2.) You have "include 'db_const.php';".... please make it like this: include('db_const.php'); 3.) Is the file "db_const.php" in the same directory as the page calling it? If your html page is in a subdirectory, e.g below the directory your db_const.php file is in, then you need your include to look like this: (include('../db_const.php'); 4.) I didn't have time to read all your html code, but I notice your <form> tag does nothing. It says <form method="post">, but post where? Usually a form tag must have an action="something.php" like this: <form method="post" action="the_page_to_post_to.php"> 5.) If after all of that the problem still persists, then put this at the top of your page: <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); foreach($_POST as $var=>$val){ echo "$var....$val<BR>"; } ?> ... and then you can see exactly what you are posting, and if you are posting what you want to post. Those 5 steps should give you all the answers you need. ...one more thing, I know you're using a prepared query, but still, you should validate that the user is actually posting an email address. You'll have to google this one. You'll want to just verify that it is a valid email WITHOUT changing the email (no preg_replace or anything -- otherwise you might end up with someone else's email). Just validate that it is a real email address before sticking it in your database.
-
Need Help to Align the logo in Center of Footer
StevenOliver replied to Naveed786's topic in PHP Coding Help
Jodunno's answer is correct. However, because I'm a lazy typer, I use an old-school hack (not real css, but works!): <div align="center"> I'm centered </div> ... or, better yet: <?php echo '<div align="center"> I'm centered </div>'; ?> That way, your post won't be in the wrong place, as this is a "PHP coding help" forum 😀 -
Especially when learning PHP (like I currently am), it is really really important to have the latest PHP and latest mySQL. I literally spent months on cleaning up my PHP 5 code only to realize that PHP 7.4 is available, and those months could have been spent learning how to code properly. So definitely upgrade your PHP and mySQL to the max. Email your shared hosting company if necessary... ask them to move you to a newer server, etc. THEN all you have to do is stick the Error Reporting code on top, and it (along with a few google searches) will actually teach you how to fix everything in your code. It is VERY satisfying to have error reporting ON, and to have no errors! Also, turn on mySQL error reporting, too (google how to do this).
-
#1.) Put at TOP of your php scripts: <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); (be sure to remove this when it goes live, you don't want public to see any errors). #2.) if((isset($_POST['submit'])) && (isset($_POST['search']) && ($_POST['search'] != NULL))) { $search = $mysqli->real_escape_string($_POST['search']); $result = $mysqli->query("SELECT * FROM careers WHERE JobTitle regexp $search"); #3.) "Job Title" or "Salary Low" etc., etc., you can't have two-word variables for mysql or php or anything. You need to do like this: jobTitle, or job_title, or jobtitle or SalaryLow, or salarylow or salary_low...... you can't have mysql columns or php variables named with words with spaces. #4.) Clean up your output. You have $output .="Job Title:$jobTitle<br /> and that's going to look like: Job Title:carpenter You would want $output .="Job Title: $jobTitle.<br /> so that it will look proper: Job Title: carpenter.
-
Great questions, SaranacLake! I want to know the answer to this one, too! Here's my 2 cents: When database queries are super-important, my code always does a "select" immediately after the "insert," just to verify the important data really got inserted properly. So, maybe: 1.) Create a simple Member Record database (e.g. Username and ID) 2.) Create a 2nd database crossreferencing the Member Record with any data you can gather (shopping cart, session ID's, IP, date, time, etc.) 3.) Verify those records are created by doing a select after the insert 4.) If records created properly, then Payment Processor. 5.) Figure out how your PHP code will know if Payment was a success or not. I dunno this one. Maybe fun reading about event loops 6.) If success, php mail a "congratulations email" to customer 7.) If no success, php mail() yourself an error, so you can fix it quick. I'll definitely watch this thread!
-
Make The Fields in a Form Table Editable
StevenOliver replied to Naveed786's topic in PHP Coding Help
Inside your <form> tags, you have <textarea name="remark" But, you do not have a name="fullname" anywhere inside your <form> tag. Therefore, the variable "fullname" never gets submitted (and thus, $fullname=$_POST['fullname'] will always be null, unless you fix that). That is why, when in development mode, you need to have Error Reporting turned on. One of the errors you would have seen is "undefined index fullname" which likely would have led to you discovering the error. 1.) Error reporting ON, during development. 2.) Declare your variables (and indexes) 3.) Use "prepared statements," or at least sanitize your data when running user-submittable mySQLi code.