include page problem

Chris S

Retired
Messages
2,055
Reaction score
1
Points
38
currently you have this

Code:
$Table .="<td>include'Action/form.php'</td>";
try something like

Code:
$Table .="<td>".require_once('Action/form.php')."</td>";
 

Anirban1987

Member
Messages
55
Reaction score
0
Points
6
currently you have this

Code:
$Table .="<td>include'Action/form.php'</td>";
try something like

Code:
$Table .="<td>".require_once('Action/form.php')."</td>";

Sorry its not working. Showing

Warning: require_once(Action/form.php</td>) [function.require-once]: failed to open stream: No such file or directory in /home/anirban/public_html/subdomains/Intranet/tdcms/cms.php on line 64

Fatal error: require_once() [function.require]: Failed opening required 'Action/form.php</td>' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/anirban/public_html/subdomains/Intranet/tdcms/cms.php on line 64
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Sorry its not working. Showing

Warning: require_once(Action/form.php</td>) [function.require-once]: failed to open stream: No such file or directory in /home/anirban/public_html/subdomains/Intranet/tdcms/cms.php on line 64

Fatal error: require_once() [function.require]: Failed opening required 'Action/form.php</td>' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/anirban/public_html/subdomains/Intranet/tdcms/cms.php on line 64

Filename there says it's trying to open 'Action/form.php</td>' - sounds like you missed a quote in the php statement somewhere.

Can you paste your new line that you're using there, cause
$Table .="<td>".require_once('Action/form.php')."</td>"; is valid and shouldn't be causing errors.
 

Anirban1987

Member
Messages
55
Reaction score
0
Points
6
Filename there says it's trying to open 'Action/form.php</td>' - sounds like you missed a quote in the php statement somewhere.

Can you paste your new line that you're using there, cause
$Table .="<td>".require_once('Action/form.php')."</td>"; is valid and shouldn't be causing errors.

I have pasted it ditto... as it is and checked it several times
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Huh, shur enough, something isn't quite right here...hang tight, running it locally now and seeing if I can't figure out why in the name of zeus this thing isn't working quite right XD


Shoulda tried it first before I said it was right I guess.



Edit: Seems include/require don't work that way, the only way to make it work is something similar to this:

Code:
$Table.="<td>";
include("Action/form.php");
$Table.="</td>";

Then in form.php:

Code:
$Table.="What have you!";

Boils down to continuing to $Table.= whatever data you're adding via Action/form.php. Since Action/form.php is being included -after- $Table has been initially set it can keep using the existing variable, including adding new stuff to the end of it :)
 
Last edited:

Hired_Goon

New Member
Messages
19
Reaction score
0
Points
0
I think " vs ' may be the cause.
Try $Table .="<td>'.require_once('Action/form.php').'</td>";

But, If Action is a directory containing form.php in your current directory then it should be
$Table .="<td>'.require_once('/Action/form.php').'</td>";



Edit
Also, Why the period after $Table and the second statement
#
$Table.= "<td>$value</td>";
#
}
#
elseif($field=='Action Taken')
#
{
#
$Table .="<td>include'Action/form.php'</td>";

contains $table<space>.=
 
Last edited:

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
I think " vs ' may be the cause.
Try $Table .="<td>'.require_once('Action/form.php').'</td>";

But, If Action is a directory containing form.php in your current directory then it should be
$Table .="<td>'.require_once('/Action/form.php').'</td>";



Edit
Also, Why the period after $Table and the second statement
#
$Table.= "<td>$value</td>";
#
}
#
elseif($field=='Action Taken')
#
{
#
$Table .="<td>include'Action/form.php'</td>";

contains $table<space>.=

1) Your new include code returns '.require_once('Action/form.php').'

I tried the include a ton of ways, none of them worked the intended way.

2) The .= means take $variable and append the stuff after .= onto it.

So:

Code:
$Table="<td>";
$Table.="Test";
$Table.="</td>";
print $Table; //$Table contains <td>Test</td>

Not sure I fully understood the question for #2 though, I just know there's no way to get include to do what Anirban wanted in 1 easy shot...There is if he puts everything in the included document into a function, but that might be more of a hassle than it's worth.
 

Anirban1987

Member
Messages
55
Reaction score
0
Points
6
Huh, shur enough, something isn't quite right here...hang tight, running it locally now and seeing if I can't figure out why in the name of zeus this thing isn't working quite right XD


Shoulda tried it first before I said it was right I guess.



Edit: Seems include/require don't work that way, the only way to make it work is something similar to this:

Code:
$Table.="<td>";
include("Action/form.php");
$Table.="</td>";

Then in form.php:

Code:
$Table.="What have you!";

Boils down to continuing to $Table.= whatever data you're adding via Action/form.php. Since Action/form.php is being included -after- $Table has been initially set it can keep using the existing variable, including adding new stuff to the end of it :)

I have done it like that. Now the form is coming but not in the intended way it should come. The form should come in each cell under Action Taken column. But it is coming on the top of the page.

The actual code that I hav pasted :
Code:
$Table .= "<td>";
$Table .= include('Action/form.php');
$Table .= "</td>";

Anybody interested can hav a look at the actual page after logging into
http://intranet.techdarpan.com/
Username and password : guest
And then go to the Content Management Panel
 
Last edited:

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
So when you're adding those buttons from Action/form.php, Action/form.php is actually doing $Table.="CodeForButtons"; ?

Cause if it's not, theres the problem - you can't do an echo if you're including it like that.


Part of what I don't get though is why you're stuffing everything into the $Table variable anyways though - why not just echo/print it all straight to screen as you go through the records?

Cause then it'd just be:

print "<td>";
include("Action/form.php"); //this prints/echos more code to the screen just as it's currently doing, rather than having to replace all the prints/echos with $Table.=
print "</td>";


This whole "store all in a variable and echo back at the very end" thing never made sense to me in any system I've seen it.
 

Anirban1987

Member
Messages
55
Reaction score
0
Points
6
So when you're adding those buttons from Action/form.php, Action/form.php is actually doing $Table.="CodeForButtons"; ?

Cause if it's not, theres the problem - you can't do an echo if you're including it like that.


Part of what I don't get though is why you're stuffing everything into the $Table variable anyways though - why not just echo/print it all straight to screen as you go through the records?

Cause then it'd just be:

print "<td>";
include("Action/form.php"); //this prints/echos more code to the screen just as it's currently doing, rather than having to replace all the prints/echos with $Table.=
print "</td>";


This whole "store all in a variable and echo back at the very end" thing never made sense to me in any system I've seen it.

Ok, now I have replaced that with
Code:
print "<td>";
include("Action/form.php"); 
print "</td>";

The 1 on the Action Taken column is now gone. Thanks. But how can I put those forms in the cells of Action Taken column ?
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Ok, now I have replaced that with
Code:
print "<td>";
include("Action/form.php"); 
print "</td>";
The 1 on the Action Taken column is now gone. Thanks. But how can I put those forms in the cells of Action Taken column ?


Inside Action/form.php, replace all your print/echo statements with $Table.=

Ergo,

Code:
Echo "<input type=whatever>";
Print "<input type=whatever2>";

becomes

Code:
$Table.="<input type=whatever>";
$Table.="<input type=whatever2>";

If you keep using Echo's and Prints in the include, it'll echo them immediately rather than storing them in $Table.
 

Anirban1987

Member
Messages
55
Reaction score
0
Points
6
Inside Action/form.php, replace all your print/echo statements with $Table.=

Ergo,

Code:
Echo "<input type=whatever>";
Print "<input type=whatever2>";

becomes

Code:
$Table.="<input type=whatever>";
$Table.="<input type=whatever2>";

If you keep using Echo's and Prints in the include, it'll echo them immediately rather than storing them in $Table.

Sorry there isn't any print or echo statement in my form. I have posted my form code in http://www.paste-it.com/view/89949080 . Have a look at it.
Edit:
Thanks everybody. I have sorted out this problem . The next problem is a bit tougher. Will describe that in a new thread.
 
Last edited:
Top