PDA

View Full Version : PHP Tutorial


lezgettdrunk
12-29-2006, 09:17 PM
I have followed the tutorial exactly, but got stuck on step 6. When I try to preview in the browser it shows me this.

Not Found

The requested URL /test/dwc.php was not found on this server.
Apache/2.0.59 (Win32) PHP/5.2.0 Server at localhost Port 80



I have entered this code:

<?php

require_once("connections/connection.php"); //database connection

$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);

echo $row['field2'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>
Could anyone help me?

davidj
12-30-2006, 04:33 PM
the path designated by apache does not match the path in dreamweaver

you need to find the path thats configured in apache

lezgettdrunk
12-31-2006, 02:27 AM
I think I understand what you are saying. I am using the wampserver and the designated path of the apache is the local host right? And that is why it cannot be found. How can I change the path of the wampserver to point to the a different directory ? Thank you!

davidj
12-31-2006, 11:22 AM
to find out where your wamp server has designated its root see figure1 and 2 below

create a blank file in DW and remove all the HTML that DW writes

in code view ad the following


<?php

phpinfo();

?>


save this off as info.php and copy it to the path that wamp server has as www root (above)

open your browser and in the address type...

http://localhost/info.php

or just click on the link above.

lezgettdrunk
12-31-2006, 02:11 PM
Wow nice details! Unfortunately I still cannot get the page to come up correctly. I created a folder on my desktop called websites and have the webroot and local root folder there.

Index of /

Icon Name Last modified Size Description
[DIR] local root/ 30-Dec-2006 20:35 -
[DIR] webroot/ 30-Dec-2006 20:36 -

Apache/2.0.59 (Win32) PHP/5.2.0 Server at localhost Port 80


When I go to my browser and type local host it shows that website folder. I can navigate to the info.php and it shows me:

Apache Environment
Variable Value
HTTP_HOST localhost
HTTP_USER_AGENT Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9
HTTP_ACCEPT text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
HTTP_ACCEPT_LANGUAGE en-us,en;q=0.5
HTTP_ACCEPT_ENCODING gzip,deflate
HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_KEEP_ALIVE 300
HTTP_CONNECTION keep-alive
HTTP_REFERER http://localhost/webroot/test/
PATH C:\academic\orawin95\bin;C:\PROGRA~1\Borland\CBUIL D~1\Projects\Bpl;C:\PROGRA~1\Borland\CBUILD~1\Bin; C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32 \Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Symantec\pcAnywhere\
SystemRoot C:\WINDOWS
COMSPEC C:\WINDOWS\system32\cmd.exe
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
WINDIR C:\WINDOWS
SERVER_SIGNATURE <address>Apache/2.0.59 (Win32) PHP/5.2.0 Server at localhost Port 80</address>
SERVER_SOFTWARE Apache/2.0.59 (Win32) PHP/5.2.0
SERVER_NAME localhost
SERVER_ADDR 127.0.0.1
SERVER_PORT 80
REMOTE_ADDR 127.0.0.1
DOCUMENT_ROOT C:/Documents and Settings/Allen/Desktop/website
SERVER_ADMIN webmaster@localhost
SCRIPT_FILENAME C:/Documents and Settings/Allen/Desktop/website/webroot/test/info.php
REMOTE_PORT 4492
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING no value
REQUEST_URI /webroot/test/info.php
SCRIPT_NAME /webroot/test/info.php
What should I do now?

davidj
12-31-2006, 03:12 PM
where ever you have webroot/test/

that is your root directory (/test/)

all your files must be placed in there for it to work through localhost

lezgettdrunk
01-01-2007, 12:08 AM
I understand that, but my files are in webroot/test. The problem is that the apache path is pointing to the folder containing the webroot & localroot folder and not to the path webroot/test. I'm trying to find out how to change the path of apache or can that not be changed?

davidj
01-01-2007, 12:21 AM
if apache is using webroot as the webroot and its not using webroot/test/ then thats fine as anything in webroot will be processed through the PHP engine

thats what you want really so you can add other working/project directories under webroot

lezgettdrunk
01-02-2007, 01:43 AM
apache is not using webroot, but using this path

C:\Documents and Settings\Allen\Desktop\website

localroot and webroot are in that folder.

So what can I do?

lezgettdrunk
01-02-2007, 02:54 AM
I tried uninstalling wamp server and changed the apache path to the

C:\Documents and Settings\Allen\Desktop\website\webroot\test

But when I hit f12 to preview in browser it shows me

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\Documents and Settings\Allen\Desktop\website\webroot\test\connec tions\connections.php on line 8

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Allen\Desktop\website\webroot\test\dwc.ph p on line 7

davidj
01-02-2007, 05:58 AM
repaste those errors again please

from the page not the post

lezgettdrunk
01-03-2007, 07:00 PM
Thank you so much for your help, but I found out what happen. It was in the dreamweaver settings on local settings. On the tutorial nothing was placed there so I did not put anything and that was why it was not connected. One more question on Tutorial 9 I am having trouble reading the code.

if ($submit __ <---I do not know what character that is

if ($submit __ $data2 __ $data3 __ $data4){

__ <-- I do not know what the character there should be (looks like a upside down question mark)

davidj
01-03-2007, 09:15 PM
if ($submit && $data2 && $data3 && $data4){

lezgettdrunk
01-04-2007, 01:44 PM
Thank you so much for your help!

davidj
01-04-2007, 02:10 PM
sorry i forgot to explain

when using IF statements

examples...

do stuff only if $var AND $var2 contain something

if($var && $var2){

do stuff

}

do stuff only if $var OR $var2 contain something


if($var || $var2){

do stuff

}


do stuff only if $var is empty or null

if(! $var ){

do stuff

}


do stuff only if $var is empty or null

if(empty($var) ){

do stuff

}

do stuff only if $var contain something

if(isset($var) ){

do stuff

}

do stuff only if $var is empty

if(! isset($var) ){

do stuff

}

do stuff only if $var is not empty and the value is greater than 5

if(! isset($var) && $var > 5){

do stuff

}


etc etc