Jump to content

learning php


j05hr

Recommended Posts

i'm new to php following a video tutorial..

using notepad they type in a php code that should say hello world on the webpage.

when a copy the code mine doesn't come up with the code

 

<html>

<head>

<title>Hello World!</title>

</head>

<body>

<?php echo "hello World!"; ?>

</body>

</html>

 

would anybody be able to tell me why it doesn't work?

thanks in advance

Link to comment
Share on other sites

  • Replies 115
  • Created
  • Last Reply

Top Posters In This Topic

i understand now..i've just finished college and plan on doing web design and just trying to learn everything through online videos. the help is much appreciated thanks

 

You'll find a lot more information in tutorials and books.  One piece of advice though:  Don't copy tutorials code for code.  Then you have no idea what you just did.  Use tutorials to introduce new concepts, not copy from.

Link to comment
Share on other sites

learning about variables now and stumbled across an error.

 

i copied the code letter for letter from the code but mine comes up with an error.

 

here's my code

 

<html>

<head>

<title>Variables</title>

<head>

<body>

<?PHP

$var1 = 10;

echo $var1;

$my_variable = "hello world";

$my_Variable = "hello world again";

echo $my_variable

echo "br />";

$var1 = 100

echo $var1;

?>

</body>

</html>

 

and this is the error message

 

Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in C:\wamp\www\php_sandbox\variables1.php on line 12

 

my code is exactly the same as the other persons so i cant see what's wrong

Link to comment
Share on other sites

i corrected that now but it didn't fix it, i'm now getting an error code saying

 

Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\php_sandbox\variables1.php on line 14

 

i may be wrong but i think its something to do with duplicating the $var1 because when i take that out it works fine

 

and as for the php being in uppercase i'm a complete noob so all constructive criticism is welcome

Link to comment
Share on other sites

i'm back again, building a content management system and come up with this error code

 

Warning: require(constants.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\widget.corp\includes\connection.php on line 2

 

Fatal error: require() [function.require]: Failed opening required 'constants.php' (include_path='.;C:\php5\pear') in C:\wamp\www\widget.corp\includes\connection.php on line 2

 

i been trying to solve it for about half an hour but can't see whats wrong, the code is

 

 

<?php

$connection = mysql_connect("localhost", "root", "telephone");

if (!$connection) {

die("Database connection failed: " . mysql_error());

}

 

// 2. Select a database to use

$db_select = mysql_select_db("widget_corp",$connection);

if (!$db_select) {

die("Database selection failed: " . mysql_error());

}

?>

<?php require_once("includes/connection.php"); ?>

<?php require_once("includes/functions.php"); ?>

<?php include("includes/header.php"); ?>

<table id="structure">

<tr>

<td id="navigation">

<ul class="subjects">

 

<?php

// 3. perform database query

$subject_set = mysql_query("SELECT * FROM subjects", $connection);

if (!$result) {

die("Database query failed: " . mysql_error());

}

 

 

while ($subject = mysql_fetch_array($subject_set)) {

echo "<li>{$subject["menu_name"]}</li>";

 

$page_set = mysql_query("SELECT * FROM pages WHERE subject_id={$row["id"]}", $connection);

if (!$page_set) {

die("Database query failed: " . mysql_error());

}

 

echo "<ul class=\"pages\">";

while ($page = mysql_fetch_array($page_set)) {

echo "<li>{$page["menu_name"]}</li>";

}

echo "</ul>";

 

}

?>

</ul>

</td>

<td id="page">

<h2>Content Area</h2>

</td>

</tr>

</table>

<?php require("includes/footer.php"); ?>

 

any help much appreciated thanks

Link to comment
Share on other sites

new error message

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\widget.corp\content.php on line 22

 

<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php include("includes/header.php"); ?>
<table id="structure">
<tr>
	<td id="navigation">
		<ul class=>"subjects">
	<?php

	$subject_set = mysql_query("SELECT * FROM subjects", $connection);
	if(!$subject_set) {
		die("Database query failed: " . mysql_error());
	}

	while ($subject = mysql_fetch_array($subject_set)) {
		echo "<li>{$subject["menu_name"]}</li>";
		$page_set = mysql_query("SELECT * FROM pages WHERE subject_id = {$subject["id"]}", $connection);
		if(!$result) {
			die("Database query failed: " . mysql_error());
		}

		echo "<ul class=\ "pages\">";
		while ($page = mysql_fetch_array($page_set)) {
			echo "<li>{$page["menu_name"]}</li>";
		}
		echo "</ul>";

	}

	?>
		</ul>
	</td>
	<td id="page">
		<h2>Content Area</h2>

	</td>
</tr>
</table>
<?php include("includes/footer.php"); ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.