Closed Logan1x closed 3 years ago
CC : @tomsik68
Now that I am able to run the test PHP script. I went into my actual folder and tried to run that. It ran successfully but not able to fetch data.
I have simple webpage which taking form data and on clicking save button redirecting to reg.php file. But on http://localhost:41062/www/reg.php
nothing opens.
Here is the repo link, if you want to look at code. https://github.com/Logan1x/php-docker
Hi, I cloned your repo, started your container like this docker run -p 41062:80 -it newtestwithnewcontainer
. Then, I created record
database and ran your sql script on it in phpmyadmin. This is what I see on localhost:41062
.
Then, I tried to click the add new
button. And I got the following php error:
[23-Feb-2021 17:35:10 Europe/Berlin] PHP Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `record`.`mydb`.`Sno` at row 1 in /www/reg.php:17
Stack trace:
#0 /www/reg.php(17): PDOStatement->execute(Array)
#1 {main}
thrown in /www/reg.php on line 17
I had to check /opt/lampp/logs/php_error_log
inside the container to find the error, but php should display errors. Since this is meant to be developer-friendly cotainer, I created #29 to track this.
Quick glance at your code suggests that your ':sno' => ''
association causes this.
https://github.com/Logan1x/php-docker/blob/c3852e26a1a1468d71b07dc6c832241005162e35/reg.php#L17
Thank you for helping out with this. Do I have to create db every time I built it? I want to push my project on docker hub so the person who is downloading image have to do create db ?
I think there's a way to create the DB inside the container. You can copy your sql script to the container and then import it with mysql cli.
Please beware that this image is not ready for production. This is merely a development environment.
Thanks I'll look into it.
Solved but got new problem see the comment below.
~Hey I used your Docker image to run my project with xampp. Before that I was testing with simple index.php file with printing my name in it.~
I used this dockerfile,
after that I built the container with this command,
but
http://localhost:41062/www/
shows only thisSo the server is running fine, but I think I am getting confused with /www directory. Can you help me out?