PDA

View Full Version : Preview Php In Browser


qazwsxedc
03-30-2007, 06:25 PM
I've followed the video tutorials so far and i'd just like to say its GREAT!!!

But i've had a problem previewing a php page in browser, the page appears blank when it should have connected to the database and echoed the results.
I've been prompted "set up testing server", does this mean i have to connect my apache to dreamweaver?

Thanks in advance:)

davidj
03-30-2007, 06:53 PM
I've followed the video tutorials

in the tuts it shows you how to configure dreamweaver

davidj
03-30-2007, 07:25 PM
post the code you have

qazwsxedc
03-30-2007, 07:27 PM
i've followed the tutorials word for word.
do i need to connect apache to dreamweaver?

qazwsxedc
03-30-2007, 07:29 PM
Sorry, your right, i've forgotten to define the site!!

qazwsxedc
03-30-2007, 07:41 PM
No, it still doesnt work.

davidj
03-30-2007, 07:44 PM
post the code you have

qazwsxedc
03-30-2007, 07:51 PM
<?php
require_once("connections/connect.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>

davidj
03-30-2007, 07:56 PM
ok first lets see if php is installed correctly

create a empty file and call it ...

info.php

in the file add the following...

<?php phpinfo(); ?>

Note: the file should be empty. Nothing in it at all apart from the code above.

then browse the file through http://localhost ..... and tell me what you see

qazwsxedc
03-30-2007, 08:19 PM
'the page cannot be found'

davidj
03-30-2007, 08:26 PM
then your browsing the wrong directory

the http://localhost/info.php is pointing to a different file to the one you saved

click the wamp5 icon in the systems tray and click the www directory

save the file in there and then browse again

qazwsxedc
03-30-2007, 08:55 PM
ok i'll try that

qazwsxedc
03-30-2007, 08:57 PM
ok, a blank page comes up, what does that mean?

davidj
03-30-2007, 08:59 PM
post the code

qazwsxedc
03-30-2007, 09:09 PM
The code is this code:

<?php phpinfo(); ?>

davidj
03-30-2007, 09:11 PM
if you look at the wamp5 icon in your systems tray what color is it

qazwsxedc
03-30-2007, 09:13 PM
A white semic circle with two black lines in the middle, it also says "WAMP5 - All Services Running - Server Offline".

davidj
03-30-2007, 09:16 PM
ok thats fine

in the browser add this in the address bar

http://localhost/

just click the link

qazwsxedc
03-30-2007, 09:23 PM
Which link? Do you mean the phpinfo()?

davidj
03-30-2007, 09:24 PM
click this.....

http://localhost/

qazwsxedc
03-30-2007, 09:27 PM
Ok. Do i have to put my php files in the www directory which is were the WAMP5 is installed in my program files?

davidj
03-30-2007, 09:28 PM
do what im asking first and tell me what you see

click....

http://localhost/

qazwsxedc
03-30-2007, 09:32 PM
lol, ok Sorry.

This is what i see:
Server Configuration

Apache version :
Apache/2.2.4 (Win32)

PHP version :
5.2.1

Loaded extensions :
bcmath, calendar, com_dotnet, ctype, session, filter, ftp, hash, iconv, json, odbc, pcre, Reflection, date, libxml, standard, tokenizer, zlib, SimpleXML, dom, SPL, wddx, xml, xmlreader, xmlwriter, apache2handler, mbstring, mysql, mysqli, PDO, pdo_sqlite, SQLite

MySQL version :
5.0.27-community-nt

Tools

phpinfo( ) (http://localhost/?phpinfo=1)
PHPmyadmin 2.9.2 (http://localhost/phpmyadmin/)
SQLitemanager 1.2.0 (http://localhost/sqlitemanager/)

Your projects

No project yet.
To create a new one, just create a directory in 'www'.

Your aliases

http://localhost/dossier.gif phpmyadmin (http://localhost/phpmyadmin/)http://localhost/dossier.gif sqlitemanager (http://localhost/sqlitemanager/)

qazwsxedc
03-30-2007, 09:38 PM
Are you able to click on the links?

davidj
03-30-2007, 09:40 PM
now on that page under Tools click...

phpinfo()

qazwsxedc
03-30-2007, 09:42 PM
did that i see a long page of details

davidj
03-30-2007, 09:44 PM
your php and server is installed and running correctly

make sure you save all your files to www directory and that you can see your file extentions and that they are .php

when you browse for them under localhost they will be there

qazwsxedc
03-30-2007, 09:48 PM
Added the files this is what i have now:

Server Configuration

Apache version :
Apache/2.2.4 (Win32)

PHP version :
5.2.1

Loaded extensions :
bcmath, calendar, com_dotnet, ctype, session, filter, ftp, hash, iconv, json, odbc, pcre, Reflection, date, libxml, standard, tokenizer, zlib, SimpleXML, dom, SPL, wddx, xml, xmlreader, xmlwriter, apache2handler, mbstring, mysql, mysqli, PDO, pdo_sqlite, SQLite

MySQL version :
5.0.27-community-nt

Tools

phpinfo( ) (http://localhost/?phpinfo=1)
PHPmyadmin 2.9.2 (http://localhost/phpmyadmin/)
SQLitemanager 1.2.0 (http://localhost/sqlitemanager/)

Your projects

http://localhost/dossier.gif localroot (http://localhost/localroot)http://localhost/dossier.gif webroot (http://localhost/webroot)

Your aliases

http://localhost/dossier.gif phpmyadmin (http://localhost/phpmyadmin/)http://localhost/dossier.gif sqlitemanager (http://localhost/sqlitemanager/)


Once i open one of the directories and open a php file i get this:


Warning: require_once(connections/connect.php) [function.require-once (http://localhost/localroot/test/images/function.require-once)]: failed to open stream: No such file or directory in F:\Program Files\wamp\www\localroot\test\images\echo.php on line 3

Fatal error: require_once() [function.require (http://localhost/localroot/test/images/function.require)]: Failed opening required 'connections/connect.php' (include_path='.;C:\php5\pear') in F:\Program Files\wamp\www\localroot\test\images\echo.php on line 3

davidj
03-30-2007, 09:53 PM
thats because you have your echo.php inside your images dir

you have this in the wrong dir

davidj
03-30-2007, 09:57 PM
NOTE: this is basic file navigation and path interpretation

if you dont understand this level of computing you need to do a basic course before you think about programming

qazwsxedc
03-30-2007, 09:57 PM
Can you tell me where this should be. I've put in a different place now (which is outside of the current directory) but it still gives me the same error?!

davidj
03-30-2007, 09:58 PM
where is your connection script?

qazwsxedc
03-30-2007, 10:00 PM
LOL, your right about taking a course! Am trying to learn it on my, harder than i thought! but thanks for the help, will keep at it, might get lucky and get it right?

qazwsxedc
03-30-2007, 10:01 PM
in a dir called Connections

domedia
03-30-2007, 10:04 PM
gazw, I think you're trying to do tutorials that are advanced, when you maybe should start with some easier ones. We all had to go through the learning curve :)

davidj
03-30-2007, 10:05 PM
the path in your script is connections/connect.php

you have used Connections (capital C). If thats the case it wont find it

move your echo out of images dir

in your www you should have this structure...

connections (dir)
images (dir)
echo.php

qazwsxedc
03-30-2007, 10:07 PM
lol, your right - i am going thorugh a tutorial i didn't think it was that advanced because it said it will start from the basics! its this one:

http://www.dreamweaverclub.com/vtm/php-mysql-apache.php

:)

davidj
03-30-2007, 10:11 PM
it does asume you have a good understanding of basic computing

its like learning to drive. The instructor assumes you know the difference between left and right.

qazwsxedc
03-30-2007, 10:15 PM
LOL, i do know basic computing! :)

its just that i am new to php. I can tell you that i have done java and C++ already to a good standard as well. its just that i am new to setting up servers...web projects etc.

Am gona try to follow tutorial again and hopefully get this to work. Will report back WHEN i am done! :)

davidj
03-30-2007, 10:32 PM
I can tell you that i have done java and C++ already to a good standard as well


if this is the case php should be childs play to you. Some one who can code proficiently in C++ and java should have no problem with path structures


i do know basic computing

if you know C++ you know advanced computing!! not basic. There is nothing basic about C++ and JAVA

MMmm i wonder

qazwsxedc
03-30-2007, 10:44 PM
Your right about C++ - and my php coding is excellent, its the dir and server business that i am new to.

-I have dealt with java's database (JDBC) using apache derby but not on a server etc.

p.s what are you wondering about ;)

davidj
03-31-2007, 09:12 AM
ok

did you get this sorted?

are you getting returns from your scripts