Joe Kdw
Joe Kdw

Reputation: 2261

failed to update category labelled inside URL

Really need help you again. I even don't know what type of question I'm facing right now. (even to add tags below this question).

enter image description here

This is the scenario:
Author wants to change the name of the category (where an article was successfully written under that category name) and update it.

Previous URL:

http://www.ramaacademy.org/programming/vb6-step-by-step.php

Need to change the URL into:

http://www.ramaacademy.org/vb6-programming/vb6-step-by-step.php

I got failed to change and update it with this follows:

$prev_url=='http://www.ramaacademy.org/programming/vb6-step-by-step.php';
$old_categ=='programming';
$new_categ=='vb6-programming';
$mod_url=substr($prev_url,0,27);

if (strpos($prev_url,$mod_url.$old_categ)) {
   $newURL==$mod_url.$new_categ;
   //UPDATING.................
   $sqlQ="UPDATE ra_articlez SET linkz=:newURL WHERE categoryz=:old_categ";
   $sth= $mydb->prepare($sqlQ);
   $sth->bindParam(':newURL', $newURL, PDO::PARAM_STR);
   $sth->bindParam(':old_categ', $old_categ, PDO::PARAM_STR);   
   $sth->execute();
   //msg
   echo "done successfully!";
}

I found no errors reported and still can not change the previous URL into new URL.
thanks for your help and suggestion!

Upvotes: 1

Views: 28

Answers (1)

don magug
don magug

Reputation: 322

I'm not sure that your question match to my try.
So far, I see no errors found in my localhost besides you just need to change old url to a new one.
but i'm trying to help you with this follows.

<?php
$datalink = "http://www.ramaacademy.org/programming/vb6-step-by-step.php";
$new_data = str_replace  ("programming", "vb6-programming", $datalink);
echo  $new_data;

?>

from the code, you can update your link:

<?php
$sqlQ="UPDATE ra_articlez SET linkz=:new_data WHERE categoryz=:old_categ";
$sth= $mydb->prepare($sqlQ);
$sth->bindParam(':new_data', $new_data, PDO::PARAM_STR);
$sth->bindParam(':old_categ', $old_categ, PDO::PARAM_STR);   
$sth->execute();
//msg
echo "done successfully!";
?>

Besides, you can get more expl. here: Stackoverflow_answer

Upvotes: 1

Related Questions