gaya Posted February 15, 2013 Share Posted February 15, 2013 for($i=0; $i<6;$i++){if($var[$i]==$str){echo "$str".$var[$i];$strfirstlettercaps = strtolower($str);$var1=$strfirstlettercaps.".php";require_once $var1; }else{$strfirstlettercaps="";$var1=fopen("$strfirstlettercaps".".php","x+");echo "<img src='../uc1.jpg'>";} The loop is checking for both if and else condition. I dont know why.please anyone tell me what i'm doing wrong here. Link to comment Share on other sites More sharing options...
Ingolme Posted February 15, 2013 Share Posted February 15, 2013 In some cases, $var[$i] is equal to $str while in others it isn't. What exactly are you doing with that fopen() statement? You're setting $strfirstlettercaps to an empty string and then asking it to open a file called ".php" Link to comment Share on other sites More sharing options...
gaya Posted February 15, 2013 Author Share Posted February 15, 2013 The fopen() is for creating an empty php file. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 15, 2013 Share Posted February 15, 2013 It's creating a file without a name, the file is called ".php". Is that what you want to name the file? 1 Link to comment Share on other sites More sharing options...
gaya Posted February 18, 2013 Author Share Posted February 18, 2013 (edited) Ya i just want to create a new empty php file like "empty.php". I did it. Now i'm trying to do,by creating that php file, i am trying to show some image.Is that possible.please tell me Edited February 18, 2013 by gaya Link to comment Share on other sites More sharing options...
rootKID Posted February 18, 2013 Share Posted February 18, 2013 (edited) hmm... im not quite into this, but tell me if im wrong, should the IMG echo not be (outside) the for if/else statement?...unless its the plan... but not sure, still having trouble understanding that kind of stuff when its coming to the part of loops and if/else statements...... Edited February 18, 2013 by rootKID Link to comment Share on other sites More sharing options...
justsomeguy Posted February 18, 2013 Share Posted February 18, 2013 Ya i just want to create a new empty php file like "empty.php". I did it.I don't think you're understanding. Look at these two lines: $strfirstlettercaps="";$var1=fopen("$strfirstlettercaps".".php","x+"); The first line sets $strfirstlettercaps to be empty, and then the second line creates a file with that as the filename. The filename of the new file is ".php". It's not "empty.php", it's just ".php" because you just set $strfirstlettercaps to be an empty string. Now i'm trying to do,by creating that php file, i am trying to show some image.I don't know what you're asking, how does the file relate to the image? Link to comment Share on other sites More sharing options...
gaya Posted February 19, 2013 Author Share Posted February 19, 2013 In the first mentioned code i simply use the if condition alone. Where i'm creating a new type,i included the code as $qtname1="$qtname"; $var1=fopen("$qtname1".".php","x+");$stringData = "<img src='../uc1.jpg'/>";fwrite($var1, $stringData);fclose($var1); In the above code $qtname is the name what i am entering newly to the database,and open the created file name included image using file write. ie)$qtname=a.php. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 19, 2013 Share Posted February 19, 2013 I don't think there's a reason for all of the extra variables and quotes, this will work fine: $var1=fopen($qtname.".php","x+"); Even so, I still don't know what you're asking. 1 Link to comment Share on other sites More sharing options...
gaya Posted February 20, 2013 Author Share Posted February 20, 2013 I'm doing a code for creating question bank for all subjects. I've dont the coding for 6different question type,like fillup,choose etc.In future, if any more new question type is added by admin,the page should not be viewed empty. Just it should show an imge like page is under construction.so i'm trying to create a empty php file and the img code sholud be written in that php file using fopen() & fwrite(). This is what i'm trying to do. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 21, 2013 Share Posted February 21, 2013 It looks like you're doing that, is the HTML not being saved in the file correctly? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now