php mod_rewrite

  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post March 24th, 2010, 2:02 am

and, did you get any errors?
Let's leave all our *plum* where it is and go live in the jungle ...
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 24th, 2010, 2:02 am

  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 2:05 am

righteous_trespasser wrote:
and, did you get any errors?

Yes :-)
Here it is
Code: [ Select ]
Notice: Undefined index: tag_dash in /home1/onlineb1/public_html/realestateproarticles/func/tag_det.inc.php on line 2

Notice: Undefined index: tag_dash in /home1/onlineb1/public_html/realestateproarticles/func/tag_det.inc.php on line 6
  1. Notice: Undefined index: tag_dash in /home1/onlineb1/public_html/realestateproarticles/func/tag_det.inc.php on line 2
  2. Notice: Undefined index: tag_dash in /home1/onlineb1/public_html/realestateproarticles/func/tag_det.inc.php on line 6


Where do I define the tag_dash?
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post March 24th, 2010, 2:08 am

"tag_dash" is a GET variable - it should be part of your url ... What URL are you at when you get these errors?
Let's leave all our *plum* where it is and go live in the jungle ...
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 2:22 am

righteous_trespasser wrote:
"tag_dash" is a GET variable - it should be part of your url ... What URL are you at when you get these errors?

Just found a typo in the .htaccess. Fixed it and now I don't get any error message, just the empty page.

In order to see it, just go to any article page at realestateproarticles(.)com and you'll see at the bottom of the page "Tags (testing!!)". Click on one of the tags.

The url from the clicked tag is a mod_rewrite url that is set in the .htaccess with this line:
Code: [ Select ]
RewriteRule ^tag/(.*)\.html$ tagdetail.php?tag_dash=$1 [L,QSA]
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 2:42 am

I think that the area to concentrate in, is tag_det.inc.php

Line 6 - I think that the check if not numeric is not relevant and even wrong.

Line 16 - I'm not exactly sure what it does or if it checks the right path

What say you?
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post March 24th, 2010, 2:49 am

Oh wait ... obviously ... just remove the following lines of code from tag_det.inc.php ...
Code: [ Select ]
if (!is_numeric ($_REQUEST['tag_dash']))
{
die();
}
  1. if (!is_numeric ($_REQUEST['tag_dash']))
  2. {
  3. die();
  4. }
Let's leave all our *plum* where it is and go live in the jungle ...
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 3:10 am

Removed.
Now I get to the "Thank you page" which is supposed to be loaded when the "else" is activated. It means that there is no match in this part:
Code: [ Select ]
if (preg_match ("/^([0-9.,-]+)$/", $blast)) {
   $blast = "true";
  1. if (preg_match ("/^([0-9.,-]+)$/", $blast)) {
  2.    $blast = "true";


How do i fix the syntax of this line to match? The value to match is placed just before .html
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post March 24th, 2010, 3:14 am

I don't even know why you check that ... but something like this might work ...
Code: [ Select ]
if (preg_match ("/^([a-zA-Z0-9.,-]+)$/", $blast)){
 $blast = "true";
  1. if (preg_match ("/^([a-zA-Z0-9.,-]+)$/", $blast)){
  2.  $blast = "true";
Let's leave all our *plum* where it is and go live in the jungle ...
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 3:32 am

righteous_trespasser wrote:
I don't even know why you check that ... but something like this might work ...
Code: [ Select ]
if (preg_match ("/^([a-zA-Z0-9.,-]+)$/", $blast)){
 $blast = "true";
  1. if (preg_match ("/^([a-zA-Z0-9.,-]+)$/", $blast)){
  2.  $blast = "true";


That worked and now I have a lot of other errors that I have to start analyze.
Many many many thanks for your great help. I'll do some checking and get back with either questions or update.

Again, thank you very very much.
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 5:11 am

After a little bit of cleaning, now I have to pass this error:

Fatal error: Call to a member function select() on a non-object in...tags_mid_1.php on line 14

tags_mid_1.php :
Code: [ Select ]
<?php

$homearticle = 5 ;


$sql = "SELECT tblarticles.intId AS artid1, tblarticles.intCategory, tblarticles.intAuthorId, tblarticles.intStatus,

tblarticles.textSummary, tblarticles.varArticleTitle, tblauthor.varFirstName, tblauthor.varlastName, tblauthor.intId

FROM `tblarticles`, `tblauthor` where (tblarticles.intStatus = 1 AND tblarticles.intAuthorId = tblauthor.intId AND tblauthor.intStatus = 1 AND tblarticles.varKeywords like '%".$tag."%')

ORDER BY tblarticles.intHit DESC LIMIT 0, $homearticle";

$result1 = $obj_db->select($sql);


?>

<ul style="list-style-image: url(/images/16dot5a.gif);">

<?php

if(isset($result1))

{



foreach ($result1 as $row)

{
$intcat = "";
$intcat = $row['intCategory'];

$sql2 = mysql_query("SELECT varCategory FROM tblcategories WHERE intID = '$intcat'");
$cat1 = mysql_fetch_assoc($sql2);
if($sql2){
$cat_list = "";
$cat_list = stripString($cat1['varCategory']);
}
$art_num = stripString($row['artid1']);
$cat_num = stripString($row['intCategory']);
$art_title = stripString($row['varArticleTitle']);
$auth_idnum = stripString($row['intAuthorId']);
$auth_fname = stripString($row['varFirstName']);
$auth_lname = stripString($row['varlastName']);
$art_sum = stripString($row['textSummary']);

$the_title = _prepare_url_text($art_title);
$the_name = $auth_fname." ".$auth_lname;
$new_name = _prepare_url_text($the_name);
?>

<li><a href="<?php echo $site_URL ?>Art/<? echo $art_num;?>/<? echo $cat_num;?>/<?php echo $the_title ?>.html" title="<? echo $art_title;?>"><h1 class="h1article_title"><? echo $art_title;?></h1></a>&nbsp;<em><font size="1">By:</font></em><a href="<?php echo $site_URL ?>Author/<?php echo $row['intAuthorId'] ?>/<?php echo $new_name; ?>.html"><font size="1"><?php echo $auth_fname." ".$auth_lname; ?></font></a><br><h2 class="h2article_title"><?php echo $art_sum; ?></h2><br>
<font size="1"><b><i>In Category -</i></b> <?php echo $cat_list ;?>

<?php
}

}
?>
  1. <?php
  2. $homearticle = 5 ;
  3. $sql = "SELECT tblarticles.intId AS artid1, tblarticles.intCategory, tblarticles.intAuthorId, tblarticles.intStatus,
  4. tblarticles.textSummary, tblarticles.varArticleTitle, tblauthor.varFirstName, tblauthor.varlastName, tblauthor.intId
  5. FROM `tblarticles`, `tblauthor` where (tblarticles.intStatus = 1 AND tblarticles.intAuthorId = tblauthor.intId AND tblauthor.intStatus = 1 AND tblarticles.varKeywords like '%".$tag."%')
  6. ORDER BY tblarticles.intHit DESC LIMIT 0, $homearticle";
  7. $result1 = $obj_db->select($sql);
  8. ?>
  9. <ul style="list-style-image: url(/images/16dot5a.gif);">
  10. <?php
  11. if(isset($result1))
  12. {
  13. foreach ($result1 as $row)
  14. {
  15. $intcat = "";
  16. $intcat = $row['intCategory'];
  17. $sql2 = mysql_query("SELECT varCategory FROM tblcategories WHERE intID = '$intcat'");
  18. $cat1 = mysql_fetch_assoc($sql2);
  19. if($sql2){
  20. $cat_list = "";
  21. $cat_list = stripString($cat1['varCategory']);
  22. }
  23. $art_num = stripString($row['artid1']);
  24. $cat_num = stripString($row['intCategory']);
  25. $art_title = stripString($row['varArticleTitle']);
  26. $auth_idnum = stripString($row['intAuthorId']);
  27. $auth_fname = stripString($row['varFirstName']);
  28. $auth_lname = stripString($row['varlastName']);
  29. $art_sum = stripString($row['textSummary']);
  30. $the_title = _prepare_url_text($art_title);
  31. $the_name = $auth_fname." ".$auth_lname;
  32. $new_name = _prepare_url_text($the_name);
  33. ?>
  34. <li><a href="<?php echo $site_URL ?>Art/<? echo $art_num;?>/<? echo $cat_num;?>/<?php echo $the_title ?>.html" title="<? echo $art_title;?>"><h1 class="h1article_title"><? echo $art_title;?></h1></a>&nbsp;<em><font size="1">By:</font></em><a href="<?php echo $site_URL ?>Author/<?php echo $row['intAuthorId'] ?>/<?php echo $new_name; ?>.html"><font size="1"><?php echo $auth_fname." ".$auth_lname; ?></font></a><br><h2 class="h2article_title"><?php echo $art_sum; ?></h2><br>
  35. <font size="1"><b><i>In Category -</i></b> <?php echo $cat_list ;?>
  36. <?php
  37. }
  38. }
  39. ?>
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post March 24th, 2010, 5:24 am

Well, look at what the error is telling you ... Have you checked line 14 ... ?

If you have, you will see that the code on that line is:
PHP Code: [ Select ]
$result1 = $obj_db->select($sql);

It tells you that you are trying to use the variable $obj_db as an object, but it has not been declared as an object ...

With that statement I can see you are trying to run a query using some kind of database/query class. I look just further down your code and there you are running a query without trying to use that class (Line 36).

Try and implement what you see on line 36 on line 14 where the error is.

Looking at this, and at the questions you are asking, I am assuming that you did not code this yourself, and you either took over a project from someone else, or just pasted code from a blog or somewhere without testing it properly. I've got to be honest with you, I don't like helping in situations like these, because through these questions you aren't really learning anything, rather just getting someone else (me) to fix your issues, and that is not what this forum is about at all ... I am not trying to be difficult or rude by saying this, I just don't want to do your work for you without you learning anything from it.
Let's leave all our *plum* where it is and go live in the jungle ...
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 5:49 am

righteous_trespasser wrote:
Well, look at what the error is telling you ... Have you checked line 14 ... ?

If you have, you will see that the code on that line is:
PHP Code: [ Select ]
$result1 = $obj_db->select($sql);

It tells you that you are trying to use the variable $obj_db as an object, but it has not been declared as an object ...

With that statement I can see you are trying to run a query using some kind of database/query class. I look just further down your code and there you are running a query without trying to use that class (Line 36).

Try and implement what you see on line 36 on line 14 where the error is.

Looking at this, and at the questions you are asking, I am assuming that you did not code this yourself, and you either took over a project from someone else, or just pasted code from a blog or somewhere without testing it properly. I've got to be honest with you, I don't like helping in situations like these, because through these questions you aren't really learning anything, rather just getting someone else (me) to fix your issues, and that is not what this forum is about at all ... I am not trying to be difficult or rude by saying this, I just don't want to do your work for you without you learning anything from it.


I've stated from the beginning that I'm not a programmer. The entire solution is based on parallel pages within the CMS script of my site. I took existing pages and customized them. It is clearly stated by the CMS developer that I purchased it from that I have full permission to do that.

You are not rude or difficult at all, you are very honest and helpful. I do learn with your assistance and yet I have no intention to be a programmer. As I mentioned before, I highly appreciate your help whether you choose to continue or stop.

Thanks
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post March 24th, 2010, 5:52 am

Cool stuff ... anyhow, did you come right ... ?
Let's leave all our *plum* where it is and go live in the jungle ...
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 6:05 am

Cool.

I've changed this line
Code: [ Select ]
$result1 = $obj_db->select($sql);

To this
Code: [ Select ]
$result1 = mysql_fetch_assoc($sql);


And now I get this message:
Code: [ Select ]
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home1/onlineb1/public_html/realestateproarticles/func/tags_mid_1.php on line 14


   Warning: Invalid argument supplied for foreach() in /home1/onlineb1/public_html/realestateproarticles/func/tags_mid_1.php on line 29
  1. Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home1/onlineb1/public_html/realestateproarticles/func/tags_mid_1.php on line 14
  2.    Warning: Invalid argument supplied for foreach() in /home1/onlineb1/public_html/realestateproarticles/func/tags_mid_1.php on line 29


So it seems that I have to check what is wrong with the select statement.
  • assaf
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jun 08, 2006
  • Posts: 40
  • Status: Offline

Post March 24th, 2010, 8:04 am

It seems that the problem was accessing the DB, so I included the config file and brought back this line:
Code: [ Select ]
$result1 = $obj_db->select($sql);

and it sorted it out.

I've checked the select statement on the DB and it works as expected. Now the issue that I'm facing is that the variable $tag is null in tags_mid_1.php so it has no impact on the where condition.

I have to find a way that it will hold the value from the calling page. I tried to add:
Code: [ Select ]
$tag_dash = $_REQUEST['tag_dash'];
$tag = str_replace ("-"," ",$tag_dash);
  1. $tag_dash = $_REQUEST['tag_dash'];
  2. $tag = str_replace ("-"," ",$tag_dash);

but it doesn't seem to work.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 24th, 2010, 8:04 am

Post Information

  • Total Posts in this topic: 32 posts
  • Users browsing this forum: No registered users and 108 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.