Jump to content

Not displaying variable


SF23103

Recommended Posts

Hey all;

 

This script gets data from a database and displays it on a page.  The page starts with header.php, then displays press_release.php, then footer.html

 

The problem is that I can echo variables on press_release.php, but not header.php.  Is it because header.php is above

$f2=mysql_result($result,$i,"submission_id");

?

 

If I move it down I get an error:  warning: mysql_numrows(): supplied argument is not a valid mysql result resource - Google Search

 

Any ideas? :-)

 

<?php

$username="XXXXXX"; // I deleted this for the purpose of this post.
$password="XXXXXXXX";
$database="XXXXXXXXX";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");


$id = $_GET['id']; //this gets the id from the url
if($id != '' && $id > 0) {  // this checks to make sure that the ID is an integer
$query="SELECT * FROM ft_form_16 WHERE submission_id='$id'"; //this pulls only that id from the database
include("/path/to/header.php"); 
} else {
   die (include "/path/to/templates/error.php"); //display error if ID is not an integer
}

/*next*/

$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"col_5");
$f2=mysql_result($result,$i,"submission_id");
$f3=mysql_result($result,$i,"col_1"); 
$f4=mysql_result($result,$i,"col_2"); 
$f5=mysql_result($result,$i,"submission_date");
$f6=mysql_result($result,$i,"col_4"); 
$f7=mysql_result($result,$i,"col_6"); 
$f8=mysql_result($result,$i,"col_7"); 
$f9=mysql_result($result,$i,"col_9"); 
$f10=mysql_result($result,$i,"col_10");
$f11=mysql_result($result,$i,"last_modified_date");
$f12=mysql_result($result,$i,"col_12"); 
$f13=mysql_result($result,$i,"col_11"); 
$f14=mysql_result($result,$i,"col_13"); 


if ($f13 == "Include") { 
include("/path/to/press_release.php");
} else { include("/path/to/unavailable.php");  //If "include" is checked, show the PR, otherwise show an error
}

$i++;
}

include("/path/to/full/footer.html"); 

?>

Link to comment
https://forums.phpfreaks.com/topic/243252-not-displaying-variable/
Share on other sites

Good call.  So if I re-arrange it, it says the query is empty.  That make sense because the code

 

$id = $_GET['id']; //this gets the id from the url
if($id != '' && $id > 0) {  // this checks to make sure that the ID is an integer
$query="SELECT * FROM ft_form_16 WHERE submission_id='$id'"; //this pulls only that id from the database
include("/home/srpdv2/public_html/press/templates/full/header.php"); 
} else {
   die (include "/home/srpdv2/public_html/press/templates/error.php"); //display error if ID is not an integer
}

 

is actually what gets the data..so I can't move it below the mysql_result's.

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.