Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
If you're serious about doing this with javascript, then pick up the nearest pen on your desk and jab yourself smartly in the eye with it, because honestly it would be less painful. Javascript is okay with cookies, which you can use to carry variables over from one page to the next, but it is not great at truly dynamic content.
If you've managed to persuade your mother that it is safe to host your own web site, then now would be a brilliant time to learn PHP, which you can install and run on your server.
Incidentally, I remember your signature said something about the nightmare your parents had when you discovered the control panel. Could this explain their reluctance to let you host a web site?
My mom said I can put something on the Internet when it has more value than a "hello world" type site.
Question: Can [PHP] work offline as well?
Her big fear is still hackers.
PHP appears like a cross between Visual Basic, JavaScript, and DOS Batch files.
This can't be too hard... (famous last words...)
Surely she understands that all great programmers begin with "hello world"!!! It's part of the learning process...
That depends on what you mean by "offline".PHP sits on the web server, and processes requests made to the web server, modifying the HTML output as required. If your web server were offline, and you were merely accessing cached versions of pages, then no, PHP would not help.If your web server is working however, then the dynamic content will be generated. And this is irrespective of whether the end user is on your LAN or beyond your router.So basically, you have the opportunity to test fully your site before you open up the relevant port on your router and let the world at large see your efforts. I think that was what you were hoping.
Again, if she is so concerned about this, perhaps HER computer should not be connected to the internet at all. Does she understand PC security? No system is 100% safe. But then that is just as true OFF the internet, what with identity theft criminals rummaging through your rubbish and all...
Well I can sort of see the point. PHP is not strictly-typed (like for example C), so it can be almost as forgiving as javascript, and it shares a lot of functionality with VB. I'm not sure the PHP developers would welcome the comparison with VB though! PHP really excels at web-based taks, particularly since they involve lots of text processing. This is where PHP is highly optimised.
Hmm...At least you can come back here if you get stuck; plus there are LOADS of PHP resources out there, as you have already discovered. If you go for PHP, bookmark >the online manual< and forget about using web design software for most of your development. Go for something like PHPEditorIDE or Notepad++. PHPEditorIDE is particularly good for starting off, because it includes PHP and CSS context-sensitive help. I prefer Notepad++ though, because it is more robust. Both provide syntax highlighting etc. Both are free (naturally). :)
Right now, I've got just HTML pages, CSS files and the like sitting on my computer. How do I put these files physically on the server so I can test them?
QuoteRight now, I've got just HTML pages, CSS files and the like sitting on my computer. How do I put these files physically on the server so I can test them?You installed Apache, didn't you? My Apache experience is all on *nix systems, so bear with me. I think the default web root is at C:\Program Files\Apache Group\Apache2\htdocs. That's where your files go.Later on, it would be desirable to edit the Apache config file, and put your webroot somewhere else - typically a top level directory on a different partition/hard drive. This slightly enhances security and tends also to enhance performance. But you can save that for another day. Apache config file editing is a black art and takes some getting used to.
<html><body><?php // If php is running correctly, this will display "Hello world!" echo '<p>Hello world!</p>';?></body>
Yes, you're up and running. Now for the web page that your mother loves so much: helloworld.php<html><body><?php // If php is running correctly, this will display "Hello world!" echo '<p>Hello world!</p>';?></body>
<!-- test1.php --><html><head><title>Test page for PHP</title></head><body><?phpsession_start("healthmeter");$_SESSION["health"] = 100;echo $health;?><p><a href="test2.php">Take off 25% health</a></p></body></html>
<!-- test2.php --><html><head><title>Test page for PHP</title></head><body><?phpsession_start()$_SESSION["health"] -= 25;echo $health?></body></html>
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\test1.php:7) in C:\Program Files\Apache Group\Apache2\htdocs\test1.php on line 8Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\test1.php:7) in C:\Program Files\Apache Group\Apache2\htdocs\test1.php on line 8Take off 25% health
Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files\Apache Group\Apache2\htdocs\test2.php on line 9
<!-- test1.php --><?phpsession_start("healthmeter");$_SESSION["health"] = 100;echo $health; ?><html><head><title>Test page for PHP</title></head><body><p><a href="test2.php">Take off 25% health</a></p></body></html>
<!-- test2.php --><?phpsession_start();$_SESSION["health"] -= 25;echo $health; ?><html><head><title>Test page for PHP</title></head><body></body></html>
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\test1.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\test1.php on line 3Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\test1.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\test1.php on line 3
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\test2.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\test2.php on line 3Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\test2.php:2) in C:\Program Files\Apache Group\Apache2\htdocs\test2.php on line 3
<?phpsession_start("healthmeter");$_SESSION["health"] = 100;?><html><head><title>Test page for PHP</title></head><body><p><a href="test2.php">Take off 25% health[/url]</p><?php echo $health;?></body></html>
<?phpsession_start();$_SESSION["health"] -= 25;?><html><head><title>Test page for PHP</title></head><body><?phpecho $health; ?></body></html>
Hmm... that's one of those things both of us should have caught, right? But who's made the bigger mistake: The guy that misreads a section of code or the guy that implements changes he has a nagging feeling that he just knows don't work right, then think up every conceivable solution except the one that works?
$health = &$_SESSION['health'];
QuoteHmm... that's one of those things both of us should have caught, right? But who's made the bigger mistake: The guy that misreads a section of code or the guy that implements changes he has a nagging feeling that he just knows don't work right, then think up every conceivable solution except the one that works?Cheeky monkey! In my defence, I was only debugging your specific errors, not checking your code for correct functioning. There's one thing that you can do to improve readability - create a reference to the session variable, thus:$health = &$_SESSION['health'];Changes then to $health will change the session variable, so you can just use $health from that point on within the script.
echo "<table>\n";
// Printing results in HTMLecho "<table>\n";while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n";}echo "</table>\n";
// Free resultsetmysql_free_result($result);
mysql_close($link);
<?php$link = mysql_connect('localhost', 'root@localhost', '********');or die('Could not connect: ' . mysql_error());echo 'Connected successfully';mysql_select_db('inventory') or die('Could not select database');$query = 'SELECT * FROM items';$result = mysql_query($query) or die('Query failed: ' . mysql_error());echo "<table>\n";while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n";}echo "</table>\n";mysql_free_result($result);mysql_close($link);?>
Parse error: syntax error, unexpected T_LOGICAL_OR in C:\Program Files\Apache Group\Apache2\htdocs\test.php on line 10
or die('Could not connect: ' . mysql_error());
<?php$link = mysql_connect('localhost', 'root@localhost', '********')or die('Could not connect: ' . mysql_error());?><p>Connected successfully</p><?phpmysql_select_db('inventory') or die('Could not select database');$query = 'SELECT * FROM items';$result = mysql_query($query) or die('Query failed: ' . mysql_error());?><table><?phpwhile ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {?> <tr><?php foreach ($line as $col_value) {?> <td><?php echo ($col_value != '' ? $col_value : ' '); ?></td><?php }?> <tr><?php}?></table><?phpmysql_free_result($result);mysql_close($link);?>
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\test.php on line 9
$link = mysql_connect('localhost', 'root@localhost', '********')
Faulting application mmc.exe, version 5.1.2600.2180, faulting module unknown, version 0.0.0.0, fault address 0x00000000.For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Hanging application msimn.exe, version 6.0.2900.2180, hang module hungapp, version 0.0.0.0, hang address 0x00000000.For more information, see Help and Support Center at
Windows saved user TIMOTHY\Timothy registry while an application or service was still using the registry during log off. The memory used by the user's registry has not been freed. The registry will be unloaded when it is no longer in use. This is often caused by services running as a user account, try configuring the services to run in either the LocalService or NetworkService account.For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
extension=php_mysql.dll
Have you definitely got an uncommented line as follows?extension=php_mysql.dll
If not, does this FAQ resolve your problem?
None of the errors you've posted/PMed are related to this problem, by the way.
Consider it done.
$link = mysql_connect('localhost', 'root@localhost', '*******')or die('Could not connect: ' . mysql_error());
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in C:\Program Files\Apache Group\Apache2\htdocs\test.php on line 9Could not connect: Can't connect to MySQL server on 'localhost' (10061)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled</title></head><body><?php$link = mysql_connect('localhost', 'root@localhost', '******')or die('Could not connect: ' . mysql_error());?><p>Connected successfully</p><?phpmysql_select_db('inventory') or die('Could not select database');$query = 'SELECT * FROM items';$result = mysql_query($query) or die('Query failed: ' . mysql_error());?><table><?phpwhile ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {?> <tr><?php foreach ($line as $col_value) {?> <td><?php echo ($col_value != '' ? $col_value : ' '); ?></td><?php }?> <tr><?php}?></table><?phpmysql_free_result($result);mysql_close($link);?> </body></html>
$link = mysql_connect('localhost', 'root', '********') or die ('Could not connect: ' . mysql_error());
do bear with me if I appear to be blind or stupid...