Jump to content

php outputting script


uswege

Recommended Posts

I am trying to output from mysql database, the code i have, which is just before the opening html tag, is this below

 

<?php include('connecting_file.php');
$catid=$_GET['cat'];
$subid=$_GET['subcat'];
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}

mysql_select_db($database_name, $pmo);
$query_cat = "select * from subcat where catid='$catid'and subid='$subid'";
$cat = mysql_query($query_cat, $pmo) or die(mysql_error());
$row_cat = mysql_fetch_assoc($cat);
$totalRows_cat = mysql_num_rows($cat);
?>

 

Then i use this one to output the content from the table by just adding this code to where i want content to appear

<?php echo $row_cat['content']; ?>

 

but all i get is

Notice: Undefined index: cat in C:\wamp\www\mysite\aboutus.php on line 2

Notice: Undefined index: subcat in C:\wamp\www\mysite\aboutus.php on line 3

 

Can someone please help me out

 

Link to comment
https://forums.phpfreaks.com/topic/223856-php-outputting-script/
Share on other sites

Both $_GET['cat'] and $_GET['subcat'] have no value. Their values need to be sent in the URL string, and checked for before attempting to use them, or executing any code that relies on their values being present.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.