Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.