0

次のように表示される書き換えられた URL があります。

http://www.coverforce.com.au/insurance-news/news/start-your-own-business-insurance/800479715/

最後の数字は、ユーザーがこの記事を読むことができるようにするために mySQL クエリで使用する必要がある URL 変数です。 mySQL データベースの記事は正しいですか?

これは私が試したものですが、うまくいきません:

<?php require_once('../Connections/newsDBconnection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$totalRows_variablearticles = "-1";
if (isset($_GET['id'])) {
  $totalRows_variablearticles = $_GET['id'];
}
mysql_select_db($database_newsDBconnection, $newsDBconnection);
$query_variablearticles = sprintf("SELECT * FROM NewsArticles, NewsArticleCategories, NewsArticlePhotos, NewsPhotos, NewsCategories WHERE NewsArticles.id = %s AND NewsArticles.id = NewsArticleCategories.newsArticleID AND NewsArticles.id = NewsArticlePhotos.newsArticleID AND NewsArticlePhotos.newsPhotoID = NewsPhotos.id AND NewsArticleCategories.newsCategoryID = NewsCategories.id", GetSQLValueString($totalRows_variablearticles, "int"));
$variablearticles = mysql_query($query_variablearticles, $newsDBconnection) or die(mysql_error());
$row_variablearticles = mysql_fetch_assoc($variablearticles);
$totalRows_variablearticles = mysql_num_rows($variablearticles);
?> 

私のウェブサイトは現在稼働中で、記事が機能していないので、あなたが提供できる助けは本当に素晴らしいです!!!

4

1 に答える 1

0
<?php

$Path = 'http://DomainName/news/articles/8008280';

//To get the innermost value  your id '8008280'

$Innermost = basename(rtrim($Path, '/'));

echo $Innermost; //will display '8008280'

// you can use article no for your query

// but make sure that article no is within the range of article no's in DB 

?>
于 2012-05-24T05:51:39.627 に答える