Jump to content
Larry Ullman's Book Forums

Recommended Posts

Chapter 9 of the book uses the ? in the url to change the data sort order and to move to extra data if the number exceeds the allowed list.

I cannot get it to work; please help

 

The script (Script 9.5 #5)creates a new url such as "http://localhost/Trial%20System%20for%20Graham/admin/view_users.php?sort=fn" but IE7 simply says it cannot find the page.

 

I have tried to separate the parts of the script and test them separately and they all seem to work. That is I can artificially create a url with ? in it, recover it and use echo to show that it has been recovered and understood. But for some reason I am totally stumped by why the complete script wont work

 

By the way it I cannot get it to work either on sorting the columns (url = "http://localhost/Trial%20System%20for%20Graham/admin/view_users.php?sort=fn" ) or on move to next page (url = "http://localhost/Trial%20System%20for%20Graham/admin/view_users.php?s=10&p=2&sort=rd")

 

Plase help before I loose all my hair

 

Trevor

Link to comment
Share on other sites

Sounds to me like the server can't find the view_users.php file at all. Are you sure your path and file name are correct? Also, while it may not be a problem, I have had issues before with using spaces in path names, and having those spaces converted to %20 improperly, etc.

 

You might want to try moving your site to a shorter, simpler path, and trying it from there. For example, in the htdocs folder (if you're using XAMPP), make a folder called test, and put the view_users.php file in there. In which case, your URL should be the following:

 

http://localhost/test/view_users.php

 

Just some thoughts.

  • Upvote 1
Link to comment
Share on other sites

Hi HartleySan

Many thanks for your advice

 

The url is generated by the script in a function called absolute url and it appears in the IE7 address bar perfectly.

Tried changing all the urls to ones without spaces (ansd all in lowercase) as that seemed a good idea

It did not work

 

I have previously tried running sections of the code on their own, such as:

CODE SECTION 1:

<tr>

 

<td align="left"><b>Edit</b></td>

<td align="left"><b>Delete</b></td>

<td align="left"><b><a href="view_users.php?sort=ln">Last Name</a></b></td>

<td align="left"><b><a href="view_users.php?sort=fn">First Name</a></b></td>

<td align="left"><b><a href="view_users.php?sort=rd">Date Registered</a></b></td>

</tr>

 

Which is the code to generate the ?sort and it works perfectly

 

CODE SECTION 2:

$sort = (isset($_GET['sort'])) ? $_GET['sort'] : 'rd';

switch ($sort) {

case 'ln':

$order_by = 'last_name ASC';

break;

case 'fn':

$order_by = 'first_name ASC';

break;

case 'rd':

$order_by = 'registration_date ASC';

break;

default:

$order_by = 'registration_date ASC';

$sort = 'rd';

break;

}

which is the section to rearrange the sort works if i try to echo $order_by just to test it.

 

But when they are combined with the section

 

$q = "SELECT last_name, first_name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr, user_id FROM users ORDER BY $order_by LIMIT $start, $display";

$r = @mysqli_query ($dbc, $q);

Which should make the lists reorder

 

It stops working and the program stops recognising the url appendage (?sort=)

 

Trevor

Link to comment
Share on other sites

Hi again HartleySan

 

I have carefully considered your advice as I felt the answer was in there somewhere. You were right. My main urls were all OK but an internal link in the program had a space in the name. I have removed this and the whole thing works perfectly.

 

 

Many, many, many thanks

 

Trevor

Link to comment
Share on other sites

I didn't do anything. In the time I was commuting home from work, you made about four posts, and logically walked your way through everything, and figured the problem out on your own. Congrats!

 

That's one of the keys to coding (and one we all have trouble with at times), debugging. It can be such a beast, but the key is breaking it into small pieces, and going from there. A good rudimentary method is to echo a lot of information at various points in the code, and see if the results are as expected.

 

Anyway, enough of that. Good job!

Link to comment
Share on other sites

 Share

×
×
  • Create New...