HighDots Forums  

PHP help needed

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss PHP help needed in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
strelitziaart
 
Posts: n/a

Default PHP help needed - 11-03-2005 , 06:11 PM






I am in the process of updating my static site to dynamic pages using php and
SQL. I have set up my sql database, made the tables and imported all the data
using a .txt file. I have set up a testing server connection in dreamweaver and
it now connects to my database and can see the tables i have made.
Now i'm stuck....How do i tell the page that i want it to get a specific piece
of data from the table and display it in the right place?

Sorry for my ignorance, but i have never done anything with static pages
before.
Help please.

Thanks
Steve


Reply With Quote
  #2  
Old   
DavidB
 
Posts: n/a

Default Re: PHP help needed - 11-03-2005 , 07:06 PM






strelitziaart wrote:

Quote:
I am in the process of updating my static site to dynamic pages using php and
SQL. I have set up my sql database, made the tables and imported all the data
using a .txt file. I have set up a testing server connection in dreamweaver and
it now connects to my database and can see the tables i have made.
Now i'm stuck....How do i tell the page that i want it to get a specific piece
of data from the table and display it in the right place?

Sorry for my ignorance, but i have never done anything with static pages
before.
Help please.

Thanks
Steve

Very simply, you have to make a database connection - a script that
references your database, usually including a database name, username
and password.

Then you have to write a query, which will include a "select" statement
referencing the tables and fields you want to draw data from.

I won't show you any examples, because I'm still working on the rough
edges, and there are SO many ways to write queries. But you can search
Google for "database connections" + MySQL + PHP and "database queries" +
MySQL + PHP, or there are others on this forum who can show you how to
do it.

Dreamweaver has automated the process, though I found it a little
confusing. Rather than be confused by Dreamweaver's PHP functions AND
regular PHP, I decided it was best to be confused by PHP alone, so I
hand code all my PHP scripts.


Reply With Quote
  #3  
Old   
strelitziaart
 
Posts: n/a

Default Re: PHP help needed - 11-03-2005 , 08:08 PM



I have already got the connection to my database. I am just having problems
with entering the correct php code to get the details off the database. I tried
<?php SELECT '*' FROM 'product' WHERE 'catalogid' = '1101'; ?> but get the
error message Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING
in /var/www/html/TMPf1qlpeog8.php on line 10

Can you tell me where i have gone wrong?

Thanks
Steve


Reply With Quote
  #4  
Old   
PeteC
 
Posts: n/a

Default Re: PHP help needed - 11-03-2005 , 08:16 PM



strelitziaart wrote:
Quote:
I have already got the connection to my database. I am just having
problems with entering the correct php code to get the details off
the database. I tried <?php SELECT '*' FROM 'product' WHERE
'catalogid' = '1101'; ?> but get the error message Parse error: parse
error, unexpected T_CONSTANT_ENCAPSED_STRING in
/var/www/html/TMPf1qlpeog8.php on line 10
You have to do a little more than that to get the info from your database.

Have a look at the examples on http://www.php.net/manual/en/ref.mysql.php -
they should get you going.

HTH,

Pete.
--
Peter Connolly
http://www.acutecomputing.co.uk
Derby
UK
Skype ID: acutecomputing




Reply With Quote
  #5  
Old   
DavidB
 
Posts: n/a

Default Re: PHP help needed - 11-03-2005 , 08:56 PM



strelitziaart wrote:

Quote:
I have already got the connection to my database. I am just having problems
with entering the correct php code to get the details off the database. I tried
?php SELECT '*' FROM 'product' WHERE 'catalogid' = '1101'; ?> but get the
error message Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING
in /var/www/html/TMPf1qlpeog8.php on line 10

Can you tell me where i have gone wrong?

Actually, that looks like a pretty simple query. But I don't think you
need any of the "stick-figure" quotes, except perhaps around 1101. I
don't believe you need to put quotes around the asterisk or around the
names of tables or table fields.

Here's one of my queries. You probably don't want to copy it verbatim,
lest you pick up any bad habits, but it works for me, and it gives you
an idea of how quotes are used:

$result = mysql_query('select count(*) from gwgeogeco');
if (($result) && (mysql_result ($result , 0) > 0)) {
} else {
die('Invalid query: ' . mysql_error());
}
{

$Kont = mysql_query("SELECT * FROM gzanimals GZA
INNER JOIN gzecoregions GZER ON GZER.Animal = GZA.Name2
INNER JOIN gwgeogeco GWEA ON GWEA.IDArea = GZER.Place
INNER JOIN gwgeog101 GEOG ON GEOG.ID101 = GWEA.KontID
WHERE GZA.Parent = '$_GET[$MyGet]' GROUP BY Kont ORDER BY N101");

if ( mysql_errno() > 0 ) {
echo mysql_error();
exit;
}
else {

{
while ( $row = mysql_fetch_array( $Kont ) ) {
$areas = array();


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.