 |
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5  | This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 23rd, 2003, 02:06 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
I also noticed an error in your JavaScript :
NEW_WIN = window.open (url, 'RecordViewer', 'toolbar=no,width=' + {$GLOBALS["new_win_width"]} + ', height= ' + {$GLOBALS["new_win_height"]} + ',directories=no, status=no, scrollbars=yes, resize=no, menubar=no');
The first argument to the window.open method should be the file path. Which I am assuming is the url parameter of the open_window() function. This was missing from your code.
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
|
|

October 22nd, 2003, 05:47 PM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I too am having trouble getting the userviewer.php document to work. I downloaded the pages placed them on my server but the View Record buttons do not work. Any suggestions? I'm on Mac - OSX, my tables are named correctly and the server is connecting to mysql. Thx
|
|

October 22nd, 2003, 06:12 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Quote:
quote:
I too am having trouble getting the userviewer.php document to work. I downloaded the pages placed them on my server but the View Record buttons do not work. Any suggestions? I'm on Mac - OSX, my tables are named correctly and the server is connecting to mysql. Thx
|
Ah a Mac user! Where in the world have all the Mac users gone??
I think what the problem boiled down to was the register_globals setting. There are many many posts that relate to how to write your code to accomadate this setting which has been set to off by default by the PHP group since I think 4.1.1 variables are accessible via new superglobal arrays that have been available since PHP 4.2.0.
Basically it boils down to this:
http://localhost/test.php?my_var=this_value
If you create a file named test.php and write the following code,
if (isset($_GET["my_var"]))
echo $_GET["my_var"];
else
echo "No way man!";
Enter in the above url and you should see "this_value" output from the script.
If a form uses a post method to transfer data variables would be created in the $_POST array.
And of course you can have a look at the hundreds of posts already on p2p that address this subject. Nikolai also made an eariler post to this thread with helpful urls that you should have a look at.
http://www.google.com/search?q=regis...e:p2p.wrox.com
Let us know if that was the problem, if not then post some code and we'll go from there.
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
|
|

October 22nd, 2003, 06:59 PM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hey, we haven't gone anywhere :D we are just working away slowlllly taking over the world.
Well is my face red!!! Turns out it was my fault. I went back and realized I had left out the useremail field in my user table. When I inserted the data, guess what, it worked.
I can only say we learn by out mistakes...and learn and learn and......
BTW thx for the fast reply!
|
|

October 22nd, 2003, 07:33 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
If I could only afford a new Mac! Those G5's have some serious shizzle under the hood.
No worries!
If we could all get it on the first try (or the thrity-forth in some cases :)) there would be no need for a forum!
I know I've had my fair share of obvious errors that take far too long to find!
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
|
|

October 29th, 2003, 02:59 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm working on the User Viewer example in chapter 12 as well. I thought I made a coding error, so I ran the script from wrox and I get the same thing. The first page is launched ok and provides the "[u]View Record</u>" links, but when the links are selected (which *should* open a new window), I get Error on Page in the bottom left corner of the browser. Pretty informative, huh? I have register_globals set on, just for the example. Anyone else seeing this? I mainly want to know if it's unusual to have a function defined within a function definition (page 438).
I find that bizarre.
I keep forgetting that my memory is slipping.
|
|

October 29th, 2003, 06:49 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
An error in the bottom left corner of the browser usually indicates a Javascript error, not a PHP or HTML error. Perhaps there's some typo or problem in the javascript you're generating. Click (or double-click) on that error icon and jot down what error(s) you're getting. View the generated source of the page and try to locate the offending javascript lines. When you discover the problem, find where those lines are being generated from within PHP and make the appropriate fixes.
If you're stuck, by all means let us know.
Take care,
Nik
http://www.bigaction.org/
|
|

October 31st, 2003, 06:13 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for responding Nik. I really appreciate you and quesadilla helping out in this forum. I wasn't sure if I managed to mismangle my files and hosed the wrox downloaded files, so I found a directory where I had uncompressed the files and copied over from there. They also fail. I'm sure it's the Javascript as you mentioned.
Outside of the warning message previously discussed (no problem there):
Notice: Undefined variable: action in c:\inetpub\wwwroot\(blah blah)\userviewer.php on line 247
I'm getting (from the little yellow ! triangle):
Line: 1
Char: 1
Error: Object expected
Code:0
URL: blah deblah/userviewer.php
"Object expected" is the error I get when I select any of the [u]View Record</u> links.
I can't imagine (being the newbie) what on earth could be causing this to fail. I'm extremely new at Javascript. I figure I can do a workaround, but I'm also troubled at the downloaded code failing and no one else mentioning having trouble.
The include file contains the definition (or declaration) of the (looks like a homemade Javascript function) nested within a PHP function definition:
function html_header() {
global $new_win_width, $new_win_height;
?>
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function open_window(url) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "RecordViewer",
"toolbar=no,width="+
<?php echo $new_win_width ?>+
",height="+<?php echo $new_win_height?>+
",directories=no,status=no,
scrollbars=yes,resize=no,menubar=no");
NEW_WIN.location.href = url;
}
//-->
</SCRIPT>
<TITLE>User Record Viewer</TITLE>
</HEAD>
<BODY>
<?php
}
This is the call from the PHP script:
<?php
while($query_data = mysql_fetch_array($result)) {
$usernumber = $query_data["usernumber"];
$userid = $query_data["userid"];
$username = $query_data["username"];
echo "<TR>\n";
echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">$usernumber</TD>\n";
echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">$userid</TD>\n";
echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">$username</TD>\n";
echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">
<A HREF=\"javascript:open_window('$PHP_SELF?action=vi ew_record&
userid=$userid');\">View Record</A></TD>\n";
echo "</TR>\n";
}
?>
I've toyed around with the Javascript in other files a little, and can get new windows to open using hardly any code. The errata section mentions this:
"A note about javascript functions
Some problems have been encountered by users when attempting to run PHP scripts incorporating javascript calls (which take the format javascript:function(), for example
javascript:open_window()). It is important to note that the call itself must contain no line breaks, or the call will not work. Note that the code download has been corrected for this problem."
This is the code download that's breaking. The error message is about as terse as you can get. A workaround won't help me understand the source of the trouble.
|
|

November 2nd, 2003, 12:05 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hmm. progress. Found a setTimeout Javascript function that may solve the problem. I've incorporated a delay opening the window to allow the url to get in there and the window launches now:
setTimeout("NEW_WIN.location.href = 'url'",1000);
Definitely system related.
|
|

November 3rd, 2003, 02:02 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That still seems odd to me.
Also -- there should be no reason for your undefined variable warning. It suggests that somewhere in your script, things can be cleaned up some more.
Finally, there's something else you mentioned that seems strange -- having a function defined within a function. What's that all about? It's illegal to define a function within a function. You can only define functions in two scopes -- global scope and class scope (for object member functions).
If you're talking about generating a JavaScript function, then you're talking apples and oranges. A Javascript function, to PHP, is just a text string in your PHP script.
Finally, can you post the generated code? I'm having trouble figuring out where the problem lies by looking at the PHP code that generates the page.
Also, you might want to try using an onClick event instead of inserting your javascript into the href.
<a href="#" onClick="open_window(...)">Link Text</a>
Take care,
Nik
http://www.bigaction.org/
|
|
 |