I cannot call another file with include function

Hello there i am trying to call my another file with include,require functions but it is showing only some of the values of the php file. I have tried it with

<?php include 'filename.php'?>

but its not working is there any of the other idea to call the file

You seem to have the syntax for include correct, although it is always safest to add a semicolon at the end.

We would probably need to see your actual code to make a diagnosis though.

1 Like

It looks like include is working ok otherwise none of the values would be showing.

[off topic]
I prefer using require instead of include because the script halts if the file cannot be loaded.
[/off topic]


Hello there help me because if i am trying you to send the code to you some of the content is missing over there so please send me the structure to send it.

My guess is that there is an error in “filename.php”. Probably right around where the last of the “some of the values” is.

Can you post that section of “filename.php” ?

	<div class="row">
  <div class="input-field col s12">
  <textarea id="txta2" class="materialize-textarea" name="title" id="word_count" cols="1" rows="1" length="120" required ></textarea>
      <label for="txta2"  name="title" required>Title Here</label>

<div class="row">
    <div class="input-field col s12">
      <textarea id="txta1" class="materialize-textarea" name="description" id="word_count" cols="1" rows="1" length="120" placeholder="I WILL BE AFFORD FOR THE JOBS RELATED TO"  required ></textarea>
      <label for="txta1"  name="description"  required >Describe Here </label>max 200characters

this is the main page

and i want to include this file which is named as a.php


<script language="javascript" type="text/javascript">
function dropdownlist(listindex)

document.formname.subcategory.options.length = 0;

switch (listindex)
    case "category1" :
        document.formname.subcategory.options[0]=new Option("subcategory1.","value1.1");
        document.formname.subcategory.options[1]=new Option("subcategory1.2","value1.2");
        document.formname.subcategory.options[2]=new Option("subcategory1.3","value1.3");

    case "category2" :
        document.formname.subcategory.options[0]=new Option("subcategory2.1","value2.1");
        document.formname.subcategory.options[1]=new Option("subcategory2.2","value2.2");
        document.formname.subcategory.options[2]=new Option("subcategory2.3","value2.3");

    case "category3" :
        document.formname.subcategory.options[0]=new Option("subcategory3.1","value3.1");
        document.formname.subcategory.options[1]=new Option("subcategory3.2","value3.2");
        document.formname.subcategory.options[2]=new Option("subcategory3.3","value3.3");

        document.formname.subcategory.options[0]=new Option("Select Category")
return true;

<title>Dynamic Drop Down List</title>


<form id="formname" name="formname" method="post" action="submitform.asp" >
<table width="50%" border="0" cellspacing="0" cellpadding="5">
<td width="41%" align="right" valign="middle">Category :</td>
<td width="59%" align="left" valign="middle"><select name="category" id="category" onchange="dropdownlist(this.options[this.selectedIndex].value);">
<option value="">Select Category</option>
<option value="category1">1</option>
<option value="category2">2</option>
<option value="category3">3</option>
<td align="right" valign="middle">Sub Category :
<td align="left" valign="middle"><script type="text/javascript" language="JavaScript">
document.write('<select name="subcategory"><option value="">Select Sub-Category</option></select>')
<noscript><select name="subcategory" id="subcategory" >
<option value="">Select Sub-Category</option>



I don’t see where the include is in that document.

I don’t see how that could work, as that begins and ends with <html> tags like it’s a whole page itself. Inserting it into some other html will not create valid html code. In fact as standalone html, it is not valid.

I don’t see any PHP code in either.

Maybe you’re looking for <iframe> ?

No SamA4 let me explain you. I have made a form in my website in which user can select categories and subcategories. And i cannot view the a.php properly and if you can suggest me any of the code related to categories and subcategories please suggest me i m not getting it.

I don’t see how the code you posted relates to the question, there is no php in the code.

Are you sure they should not be the other way around and the first block of code is included in the second?

sure exactly like that only.

Hello there i am facing a little bit of more doubt and the doubt is that if individually i am running the the page of category and subcategory i am getting the values 0 inserted into mysql database so what is the main reason behind getting the null values into mysql database please help me i have researced it a lot but not getting it…

It’s hard to say without seeing the code. If you call the pages directly and get 0 inserted, that sounds as if you need the pages to be called in a specific way, and are not checking for invalid values before writing data into the database. But I’m guessing without seeing the code.

I have soved the error i was facing off the problem was that i have taken datatype as INTEGER instead of VARCHAR that i saw today and it works fine…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.