JRA Posted October 9, 2017 Posted October 9, 2017 (edited) Hi - sorry ran out of characters in the title. Well I'm fairly new to Dreamweaver tbh, and know a 'bit' of MySQL but no huge genius. As per the new controlled assessment, I'm trying to do a 'dry run' with a student account and get the output of a MySQL table into a web page in Dreamweaver. I've tried and failed with mysql_connect in php (but to be honest I don't really 'know' what I'm doing, just copying and pasting code and amending login details and column names etc.) We have a Ubuntu/MySQL server set up for students to use, which works fine. Anyone have a REALLY basic guide on how to do this? Thanks to anyone reading! Edited October 9, 2017 by JRA
mavhc Posted October 9, 2017 Posted October 9, 2017 Does more basic php work? Does connecting to the database remotely from the command line work? Paste the code you're using and the errors you get. 1
JRA Posted October 9, 2017 Author Posted October 9, 2017 (edited) Thanks mavhc. At the moment, looks like the following (edited slightly:) $username="tkid3";$password="umbrella"; $database="tkid3_testdb";mysql_connect("compsci.mynetwork.mydomain.sch.uk",$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM students";$result=mysql_query($query); $num=mysql_numrows($result);mysql_close();?> </pre><table border="0" cellspacing="2" cellpadding="2"> Value1 Value2 Value3 Value4 Value5 $i=0;while ($i < $num) {$idnumber=mysql_result($result,$i,"idnumber"); $surname=mysql_result($result,$i,"surname"); $forename=mysql_result($result,$i,"forename"); $dob=mysql_result($result,$i,"dob"); $homeaddr=mysql_result($result,$i,"homeaddr");?> $i++;}?> </table><br><br><br><br><br> <title>PHP Test</title><br><br><br>PHP WORKS'; ?><br><br><br>< Edited October 9, 2017 by JRA
mavhc Posted October 9, 2017 Posted October 9, 2017 There's code tags for making code display properly, [ code ] 1
JRA Posted October 9, 2017 Author Posted October 9, 2017 There's code tags for making code display properly, [ code ] Heh, yes I was struggling to get that legible! I'll amend it now...
ollyyllo Posted October 9, 2017 Posted October 9, 2017 Are you aware of this: mysql_connect Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: PHP: mysql_connect - Manual 1
JRA Posted October 9, 2017 Author Posted October 9, 2017 Okay, I don't know if I'm missing things here, but I'm quite new to all of this. I might be far in over my head already. If anyone's reading who can steer me right I'd definitely appreciate it! So, I'm opening Dreamweaver on a PC. MySQL server is a Ubuntu server. I don't seem able to get anything php-related to work. As in, not in Dreamweaver nor if I just stick php functions in text/.html files and open them in Chrome or Firefox. Is this because I don't have php installed on this PC? I'm fairly sure I don't, but if so, has anyone got 'set up' for this new controlled assessment? Would an approach for it be to give the students a login to the server itself, a home area, install php on that and do *something*? Gosh I really am tangled here. :/ Thanks for any and all assistance.
mavhc Posted October 9, 2017 Posted October 9, 2017 Either you install a web and database server on each computer, or on a server and everyone has a login. If you name a file .php and put it on the ubuntu server, then with php enabled on that server it should just work. You seem to have 2 html files in 1 file in your posting of the code though. Only one .... per file. 1
JRA Posted October 9, 2017 Author Posted October 9, 2017 (edited) Ooh this is good, this is good! Just so I've got this straight (and to confirm in case anyone else is watching and desperate) an approach in the single-server scenario would be: - Ubuntu server with MySQL set up the way we did back in the day. - Get Samba, winbind, Apache on it. Samba and winbind for a share for each punter, Apache for the php support. Probably already done php/web parts if going through the previous. - Do the php bit and MySQL bit in Dreamweaver on Windows classroom client as per these instructions. That hold water or have I still got it poopy? Thanks to you all so much for the spoon-feeding! Edited October 9, 2017 by JRA
mavhc Posted October 9, 2017 Posted October 9, 2017 Sounds about right, you can join samba to your AD to avoid creating new accounts, depends if you're doing 30 or 300 users, https://runops.wordpress.com/2015/03/19/how-to-setup-active-directory-authentication-in-mysql-running-on-linux/ Probably best to just create them on linux. You could of course run it on all windows server. 1
PotNoodleTech Posted October 10, 2017 Posted October 10, 2017 Does it have to be MySQL? Was just thinking that you could use an access database as the backend and still do all of the things in dreamweaver that you could do in MySQL - apart from obviously directly programming the mysqldatabase. Seems to be would be a lot easier for pupils to connect to a DB in their my documents. Ignore me if I am way off the mark. 1
PyROm Posted October 11, 2017 Posted October 11, 2017 Havent looked at this as no one has mentioned it to me yet, but might be worth considering SQLlite as well as it is a file based server that might be easier to handle per student (and has standard sql command syntax). With using access .mdb as a mssql database, dont you have to set it up as an odbc source, or is there a way around that? 1
PotNoodleTech Posted October 11, 2017 Posted October 11, 2017 Havent used dreamweaver for a long time but I believe you can still connect to an access DB on a file share by using a custom connection string (rather than ODBC). I guess it depends which version the last version I used in anger was Dreamweaver Ultradev back when the internet was on 56k modems! 1
mavhc Posted October 11, 2017 Posted October 11, 2017 Why are kids still being taught to use dreamweaver? for all those 90s website jobs? They should be setting up wordpress and git, etc, something people actually use. 2
PotNoodleTech Posted October 11, 2017 Posted October 11, 2017 Why are kids still being taught to use dreamweaver? for all those 90s website jobs? They should be setting up wordpress and git, etc, something people actually use. I do kinda agree. I set up a website not long ago, online ordering etc. Used shopify. Took me a couple if hours to set up the whole site, from nothing, to good looking website, online ordering enabled, linked to bank account and paypal, link to facebook/twitter etc for automatic posting of new products and news and all for £20/month fully hosted. It's bonkersly easy and fast and cheap with these modern websites. Back in the old days that would have taken weeks with dreamweaver! 1
PyROm Posted October 11, 2017 Posted October 11, 2017 I can just see the commands now... "git checkout PornStar", "git pull bird" etc. We used a raspberry pi emulator a while ago (vm basically running raspberry pi os), we had it copy the harddrive image over to the users local profile on the machine if it didnt already exist when you ran it, then start it up, so each user ran their own copy and couldnt interfere with each other. Wouldnt be too big a job to setup debian with mysql running on it and loopback networking. That way they could all have access to their own personal mysql server, maybe even if you could get vm passthrough a folder you could have apache serve files from the vm saving setting up apache/iis on the windows machines to run php. 1
JRA Posted October 17, 2017 Author Posted October 17, 2017 I'd make them all do something useful in html for a little while. Maybe some php, and maybe a nod towards WordPress (which seemingly runs the internet) and yeah even Dreamweaver. But I'm clearly not visionary/drunk enough to work for OCR and come up with this garbage. - - - Updated - - - Does it have to be MySQL? Was just thinking that you could use an access database as the backend and still do all of the things in dreamweaver that you could do in MySQL - apart from obviously directly programming the mysqldatabase. Seems to be would be a lot easier for pupils to connect to a DB in their my documents. Ignore me if I am way off the mark. Hi - yeah it does have to be MySQL and Dreamweaver.
JRA Posted October 20, 2017 Author Posted October 20, 2017 Okay, I *think* I'm getting close! I cannot for the life of me set up 'per user' sites with Apache2 on my little compsci server for the punters. I mean kiddies. Followed this decent-looking guide HERE but still not there, getting "403 Forbidden" on the student account. In a nutshell, the students doing the assessment will be given a 'second' little home area in which to do their thing. In this second home area, they should be instructed to make a folder called 'site' (or I could script that, I might.) In there, all the website things will go, as well as a file called "file.html" which I'm using for my test account. Their home areas aren't in /homes, rather in /compscihomes/username/ - this is all fine in Samba and seems to deploy ok at logon as X: apache2.conf looks like this: # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See http://httpd.apache.org/docs/2.4/ for detailed information about # the directives and /usr/share/doc/apache2/README.Debian about Debian specific # hints. # # # Summary of how the Apache 2 configuration works in Debian: # The Apache 2 web server configuration in Debian is quite different to # upstream's suggested way to configure the web server. This is because Debian's # default Apache2 installation attempts to make adding and removing modules, # virtual hosts, and extra configuration directives as flexible as possible, in # order to make automating the changes and administering the server as easy as # possible. # It is split into several files forming the configuration hierarchy outlined # below, all located in the /etc/apache2/ directory: # # /etc/apache2/ # |-- apache2.conf # | `-- ports.conf # |-- mods-enabled # | |-- *.load # | `-- *.conf # |-- conf-enabled # | `-- *.conf # `-- sites-enabled # `-- *.conf # # # * apache2.conf is the main configuration file (this file). It puts the pieces # together by including all remaining configuration files when starting up the # web server. # # * ports.conf is always included from the main configuration file. It is # supposed to determine listening ports for incoming connections which can be # customized anytime. # # * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ # directories contain particular configuration snippets which manage modules, # global configuration fragments, or virtual host configurations, # respectively. # # They are activated by symlinking available configuration files from their # respective *-available/ counterparts. These should be managed by using our # helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See # their respective man pages for detailed information. # # * The binary is called apache2. Due to the use of environment variables, in # the default configuration, apache2 needs to be started/stopped with # /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not # work with the default configuration. # Global configuration # # # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # NOTE! If you intend to place this on an NFS (or otherwise network) # mounted filesystem then please read the Mutex documentation (available # at ); # you will save yourself a lot of trouble. # # Do NOT add a slash at the end of the directory path. # #ServerRoot "/etc/apache2" # # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. # Mutex file:${APACHE_LOCK_DIR} default # # PidFile: The file in which the server should record its process # identification number when it starts. # This needs to be set in /etc/apache2/envvars # PidFile ${APACHE_PID_FILE} # # Timeout: The number of seconds before receives and sends time out. # Timeout 300 # # KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to "Off" to deactivate. # KeepAlive On # # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # We recommend you leave this number high, for maximum performance. # MaxKeepAliveRequests 100 # # KeepAliveTimeout: Number of seconds to wait for the next request from the # same client on the same connection. # KeepAliveTimeout 5 # These need to be set in /etc/apache2/envvars User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP} # # HostnameLookups: Log the names of clients or just their IP addresses # e.g., www.apache.org (on) or 204.62.129.132 (off). # The default is off because it'd be overall better for the net if people # had to knowingly turn this feature on, since enabling it means that # each client request will result in AT LEAST one lookup request to the # nameserver. # HostnameLookups Off # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a # container, that host's errors will be logged there and not here. # ErrorLog ${APACHE_LOG_DIR}/error.log # # LogLevel: Control the severity of messages logged to the error_log. # Available values: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the log level for particular modules, e.g. # "LogLevel info ssl:warn" # LogLevel warn # Include module configuration: IncludeOptional mods-enabled/*.load IncludeOptional mods-enabled/*.conf # Include list of ports to listen on Include ports.conf # Sets the default security model of the Apache2 HTTPD server. It does # not allow access to the root filesystem outside of /usr/share and /var/www. # The former is used by web applications packaged in Debian, # the latter may be used for local directories served by the web server. If # your system is serving content from a sub-directory in /srv you must allow # access here, or in any related virtual host. Options FollowSymLinks AllowOverride None Require all denied AllowOverride None Require all granted Options Indexes FollowSymLinks AllowOverride None Require all granted # # Options Indexes FollowSymLinks # AllowOverride None # Require all granted # # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess # # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # Require all denied # # The following directives define some format nicknames for use with # a CustomLog directive. # # These deviate from the Common Log Format definitions in that they use %O # (the actual bytes sent including headers) instead of %b (the size of the # requested file), because the latter makes it impossible to detect partial # requests. # # Note that the use of %{X-Forwarded-For}i instead of %h is not recommended. # Use mod_remoteip instead. # LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent # Include of directories ignores editors' and dpkg's backup files, # see README.Debian for details. # Include generic snippets of statements IncludeOptional conf-enabled/*.conf # Include the virtual host configurations: IncludeOptional sites-enabled/*.conf # vim: syntax=apache ts=4 sw=4 sts=4 sr noet # ADDED BY ME FOR HOMEDIR APACHE: # Include httpd-userdir.conf #ADDED BY ME TO ACTUALLY GET HTTPD.CONF IN AND WORKING LIKE THE TUTORIALS SAY: # Include /etc/apache2/httpd.conf .../mods-enabled/userdir.conf is: UserDir public_html UserDir disabled root AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require all granted Require all denied # vim: syntax=apache ts=4 sw=4 sts=4 sr noet .../mods-available/php7.0.conf looks like: SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source # Deny access to raw php sources by default # To re-enable it's recommended to enable access to the files # only in specific virtual host or directory # Require all denied <-- WAS this, commented it out and put in the next two lines Order Deny,Allow Deny from all # Deny access to files without filename (e.g. '.php') # Require all denied <-- I also edited this out, and put in the next two lines: Order Deny,Allow Deny from all # Running PHP scripts in user directories is disabled by default # # To re-enable PHP in user directories comment the following lines # (from to .) Do NOT set it to On as it # prevents .htaccess files from disabling it. # I ALSO COMMENTED OUT ALL THE FOLLOWING TO THE END: # # # php_admin_flag engine Off # Anyone got any ideas what I'm doing? Very grateful indeed for any pointers at this stage!
PyROm Posted October 20, 2017 Posted October 20, 2017 In your userdir.conf you have changed their example, you have used "UserDir public_html", I believe if you chage this you also need to change the line "" to "" 1
JRA Posted October 20, 2017 Author Posted October 20, 2017 Cheers! Okay done that, still not sure I've got it. userdir.conf is as follows: UserDir /compscihomes/*/public_html UserDir disabled root AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require all granted Require all denied # vim: syntax=apache ts=4 sw=4 sts=4 sr noet I've tried with and without making a /public_html folder in the new little home areas, trying to use the 'site' folder or not, but getting 403 errors still. Even if there's no file in there at all, and no matter what folder I seem to steer that to. Feels like I'm getting near though!
pcstru Posted October 20, 2017 Posted October 20, 2017 Just to check, how are you constructing the URL? What is the server responding with? 1
PyROm Posted October 20, 2017 Posted October 20, 2017 As a quick check, has the user the webserver is running as got permission to the folder? quick test would be to chmod -R 777 public_html. Have you tried it with a straight index.html file as well (also with right permissions). Have you tried putting the file your trying to view on the end rather than relying on it auto fiinding the default index? ie goto http://server/user/public_html/index.html 1
PyROm Posted October 20, 2017 Posted October 20, 2017 another thought is look in /var/log/apache2/access_log and error_log for clues. 1
JRA Posted October 20, 2017 Author Posted October 20, 2017 Thanks both! Url is: http://compsci/~tkid3/file.html I get: Forbidden You don't have permission to access /~tkid3/file.html on this server. Apache/2.4.18 (Ubuntu) Server at compsci Port 80 I chmod-ed that wide open too, but still get the same. I also get similar if I put in some nonsense url eg: http://compsci/~tkid3/toilet.html Thanks though everyone for the hand-holding!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now