Forum Moderators: coopster

Message Too Old, No Replies

Dreamweaver MX: PHP Web Development

Having trouble with tutorial, clients info not showing

         

aaronjf

6:44 pm on May 29, 2003 (gmt 0)

10+ Year Member



I am currently trying to teach myself PHP / MySQL. I have been working from the tutorial in ÒDreamweaver MX: PHP Web DevelopmentÓ from Glasshaus ISBN # 1-904151-11-6.

I am having some problems with the Change Booking Details page. It seems to be pulling the Booking information, but not the clients information (name, address, etc). Has anyone else worked with this and if you have did you experience problems? Could creating multiple bookings for the same client been creating the problem?

As I am a PHP newbie I am at a total loss here.

jatar_k

9:59 pm on May 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



any idea what specific bit of code is causing the problem?

How exactly is it misbehaving? Is the client info taken from a mysql call? Is it not passing the proper ID/info to said query?

aaronjf

10:13 pm on May 29, 2003 (gmt 0)

10+ Year Member



Not totally sure. It is passing the appropiate info.

It is calling from two differnt MySQL tables, Bookings and Clients. The information that should be coming from the Clients table to fill the page is what is not working. All the information form the Booking table seems to be coming in fine.

I am able to revieve the information from and send to the Clients talbe on other pages.

jatar_k

10:14 pm on May 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Does it do a join to get all of the data or does it do 2 seperate queries?

aaronjf

10:40 pm on May 29, 2003 (gmt 0)

10+ Year Member



No not a join. Here is the code associated with the booking and client table recordset

<?php
$colname_rsBookings = "1";
if (isset($HTTP_POST_VARS['bookingID'])) {
$colname_rsBookings = (get_magic_quotes_gpc())? $HTTP_POST_VARS['bookingID'] : addslashes($HTTP_POST_VARS['bookingID']);
}
mysql_select_db($database_connTheRabbitHole, $connTheRabbitHole);
$query_rsBookings = sprintf("SELECT * FROM bookings WHERE ID = %s", $colname_rsBookings);
$rsBookings = mysql_query($query_rsBookings, $connTheRabbitHole) or die(mysql_error());
$row_rsBookings = mysql_fetch_assoc($rsBookings);
$totalRows_rsBookings = mysql_num_rows($rsBookings);

mysql_select_db($database_connTheRabbitHole, $connTheRabbitHole);
$query_rsClient = "SELECT * FROM clients WHERE ID = $row_rsBookings['clientID']";
$rsClient = mysql_query($query_rsClient, $connTheRabbitHole) or die(mysql_error());
$row_rsClient = mysql_fetch_assoc($rsClient);
$totalRows_rsClient = mysql_num_rows($rsClient);
?>

jatar_k

10:53 pm on May 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



have you tried echo'ing $query_rsClient and $totalRows_rsClient?

$totalRows_rsClient should be > 1 and $query_rsClient will allow you to check the query to make sure it is being properly constructed.

aaronjf

11:11 pm on May 29, 2003 (gmt 0)

10+ Year Member



How do I echo?

jatar_k

11:13 pm on May 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



mysql_select_db($database_connTheRabbitHole, $connTheRabbitHole);
$query_rsClient = "SELECT * FROM clients WHERE ID = $row_rsBookings['clientID']";

echo "<p>",$query_rsClient;

$rsClient = mysql_query($query_rsClient, $connTheRabbitHole) or die(mysql_error());
$row_rsClient = mysql_fetch_assoc($rsClient);
$totalRows_rsClient = mysql_num_rows($rsClient);

echo [php.net] "<p>",$totalRows_rsClient;

aaronjf

3:32 am on May 30, 2003 (gmt 0)

10+ Year Member



I get the same error after replacing my code with yours.. man I am so lost.

This is the response I get:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site141/fst/var/www/html/server_side/reservation/bookings/change_booking_details.php on line 14

Line 14 = $query_rsClient = "SELECT * FROM clients WHERE ID = $row_rsBookings['clientID']";

jatar_k

3:35 am on May 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try this

$query_rsClient = "SELECT * FROM clients WHERE ID = ".$row_rsBookings['clientID'];

<added>debugging takes a long time in this environment

aaronjf

3:40 am on May 30, 2003 (gmt 0)

10+ Year Member



The page loads without the error now, but still does not return client's info.

What does the "." do?

<added> strange thing is I am using the WYSIWYG DW MX PHP. I am not hand coding, just following the instructions from the book and trying to understand what is going on. Perhaps I should go back to basics and just start by trying to learn to hand code...

BTW: Did you get that FedEx users guide I sent you yesterday? Was it what you were looking for?

jatar_k

3:43 am on May 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



yes i did thanks

the . is the concatenation operator so you patch the string together and put it into the variable.

did you get it to echo the contents of the variable then?

<added>I have to admit that I hate WYSIWYG's anyway but especially for php, rather do it myself.

aaronjf

3:54 am on May 30, 2003 (gmt 0)

10+ Year Member



did you get it to echo the contents of the variable then?

If it was a snake it would have bit me. I have know idea what I would be looking for from an echo...

jatar_k

4:13 am on May 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



essentially echo'ing the contents of the var is used to test to make sure that values are being passed/constructed correctly.

When you echo the contents you can see what exactly is getting passed to the mysql_query function to see if that is what is erroring out.

aaronjf

4:16 am on May 30, 2003 (gmt 0)

10+ Year Member



So should it show an error message on the page, or what should I be looking for?

jatar_k

4:21 am on May 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



depending on where that particular line is situated in regards to the html it may come up in the browser or only when you view source.

try
echo "<p>query: ",$query_rsClient;

that will help you find it, somewhere there will be a paragraph tag with "query: " and the value of the var.

stever

4:36 am on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not wanting to take away from this discussion - but I believe there were a bunch of errata for this book, which went down when glasshaus died.

However, I understand the author, who can be contected through his website, still has copies of them. You might want to ask nicely?

mincklerstraat

8:58 am on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if you aren't yet familliar with echo, when you try to debug your code, you will be really lost. Even if you're using a tool like Dreamweaver, there's nothing like having a basic knowledge of PHP. It's not so hard at all to get the gist of the PHP basics, and a good PHP book for this is is a godsend -- I've looked the Hungry Minds PHP /MySQL, and it seemed very nice, better than the one I started on. I've heard concerns about Dreamweaver making inefficient or error - ridden code, a lot of people use Dreamweaver to make cool HTML pages, and just write their own PHP code.

aaronjf

3:56 pm on May 30, 2003 (gmt 0)

10+ Year Member



stever

Yeah, I saw that the site was down, what gives. I had noticed a lot of errors in the books, but was starting to think it was just me. I will contact the author.

mincklerstraat

On my way to work I stopped and picked up a copy of O'Rielly's "Creating Dynamic Web Pages: Programming PHP" By Rasmus Lerdorf & Kevin Tatroe. I am going to go back to the drawing board and learn the hand coding. I was hoping to pick it up while doing the tutorials, but I am not picking it up quick enough from the tutorial to understand what is going on exaclty.

bcolflesh

4:01 pm on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My favorite beginner PHP book:

PHP and MySQL Web Development
by Luke Welling, Laura Thomson
ISBN: 0672317842

Regards,
Brent