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

Link to comment
Share on other sites

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.