Jump to content

Fallen_angel

Members
  • Posts

    88
  • Joined

  • Last visited

    Never

Everything posted by Fallen_angel

  1. This is the example your looking for: Code: <?php /* This example assumes that www.example.com is configured to parse .php * files and not .txt files. Also, 'Works' here means that the variables * $foo and $bar are available within the included file. */ // Won't work; file.txt wasn't handled by www.example.com as PHP include 'http://www.example.com/file.txt?foo=1&bar=2'; // Won't work; looks for a file named 'file.php?foo=1&bar=2' on the // local filesystem. include 'file.php?foo=1&bar=2'; // Works. include 'http://www.example.com/file.php?foo=1&bar=2'; $foo = 1; $bar = 2; include 'file.txt'; // Works. include 'file.php'; // Works. ?> If your going to include a file, with ?foo=1&bar=2, you need to use an absolute path. Thankyou both very much , thats is exactly what i was tryign to go through but it wasn't workign for me however yes the full path was working but not apropriate for the situation this script is setup in unfortunatly. I have ended up goign with $_GET['id]=foo ; include "file.php" ; then on the other page i simply pulled the get vairable out and it works wonderfully thankyou both so so much again
  2. Hi , I am hopign someon can help me out here I am trying to use the following include include "./file.php?foo=var1&bar=var2" ; However its not working because the server is obiously looking for a file called "file.php?id=var1&bar=var2" not just file.php then parsing the variables to it. I have read a few peoples sugestions in the includes manual liek settign the variable outside of the include and then passing it into the include itself ie $vars= '?foo=var1&bar=var2' ; include './file.php$vars ; : but that did what i thought it would and just spat back the same error. I am sure it's the variable thats causign the issue because when i take it away the include works however this makes it so that my script doesn't work properly without manually setting the variable Thanx to anyone that can help out
  3. Ok figured it out for some reason my script didn';t liek the collom with the name group no matter what i put in there , however as soon as i changed group to grp it worked so go figure lol could someone possibly explain that cause i have the script workign now but i'm kinda scratching my head as to what i did wrong before
  4. I relised that I made an error with my example I gave i put $group[]=$_POST['location[]'] ; instead of just $group=$_POST['location'] ; after doing some more testign i have discovered the issue is when i add a certain feild of my database to the sql script , even if I vet the value manually it still makes the whoel thing fail so the issue is in part of my sql script that I'm sure i can knuckle out thanx anyways hehe
  5. Hi , I am having a bit of an issue getting a foreach statement i have made to work , essentially what this for each statement is suposed to do is write a row to a database for each one of the check boxes selected here is the code <Form enctype='multipart/form-data' action="process_add_banner.php" method="post"> <input type='hidden' name='send' value='1' /> <tr><td>Name:</td><td><input type="Text" name="name"><br></td></tr> <tr><td>Locations</td><td> <table width="100%"> <tr ><td><INPUT TYPE=CHECKBOX NAME="location[]" VALUE="None">None</td> <td><INPUT TYPE=CHECKBOX NAME="location[]" VALUE="Forums">Fourms</td> <td><INPUT TYPE=CHECKBOX NAME="location[]" VALUE="Extras">Extras</td> <td><INPUT TYPE=CHECKBOX NAME="location[]" VALUE="Portal">Portal</td> </tr> </table> </td><tr> <tr><td></td><td><input type="Submit" name="submit" value="Submit Information"></td><tr> </form> and the processing code is $name=$_POST['name']; $group[]=$_POST['location[]'] ; foreach ($group as $loc) { $sql = "INSERT INTO database (name,group) VALUES ('$name','$loc')"; $result = mysql_query($sql); } Can someone please tell me where i am going wrong ? I don't get any syntax errors it just doesn't do the insert . Thanx allot for your assistance
  6. I have a script in which I allow users to upload 4 files , this script works fine and does the job I want perfectly , However I wanted to add a comments section for each of the images , I tried playing around a little but I can't seem to get it to work so if someon could help me here i woudl really apreciate it the relivant part of the forum itself says <?php // max number of files allowed to upload at one tome define ( 'MAX_FILES', '4' ); for ( $i = 1; $i <= MAX_FILES; $i++ ) { echo " <tr><td>Image Comments</td><td><TEXTAREA rows='2' cols='35' name='comments[$i]' ></textarea></td></tr>\r\n"; echo " <tr><td>Select image</td><td><input type='file' name='up[$i]' size='36'></td></tr>\r\n"; echo " <br />\r\n"; } ?> Now as mentioned the "up" one works fine as part of the bellow upload script however I am not sure how to echo the comments on the next page which is what i need help with <?php define ( 'UPLOAD_PATH', '../uploads/' ); // max number of files allowed to upload at one tome define ( 'MAX_FILES', '4' ); // define the max single file size (bytes) define ( 'MAX_SIZE', '1048576' ); // allowed types $allow = array ( 'png', 'jpg' ); /* e - config */ if ( ! empty ( $_POST['send'] ) ) { $return = array(); $x = 1; for ( $i = 1; $i <= sizeof ( $_FILES['up'] ); $i++ ) { if ( is_uploaded_file ( $_FILES['up']['tmp_name'][$i] ) ) { if ( $_FILES['up']['tmp_name'][$i] != 'none' ) { $ss = filesize ( $_FILES['up']['tmp_name'][$i] ); if ( $ss > 10 && $ss <= MAX_SIZE ) { $sn = strtolower ( $_FILES['up']['name'][$i] ); $ran= md5(rand() * time()); // make a random filename $randName = $ran."." ; $ce = substr ( $sn, ( strrpos ( $sn, '.' ) + 1 ) ); if ( in_array ( $ce, $allow ) ) { if ( move_uploaded_file ( $_FILES['up']['tmp_name'][$i], UPLOAD_PATH . $randName.$ce ) ) { $return[$x]['name'] = $randName; $return[$x]['type'] = $ce; $return[$x]['size'] = $ss; $x++; } } } } } } } ?> <html> <head> <?php if ( ! empty ( $return ) ) { ?> <div align='center'> <table width='672'> <tr> <td align='center'>FILES UPLOADED</td> </tr> <tr> <td> <table width='100%'> <tr> <td align='center' width='4%' height='21'>#</td> <td width='2%'></td> <td align='center' width='52%' height='21'>FILE NAME</td> <td width='2%'></td> <td align='center' width='24%' height='21'>FILE SIZE</td> <td width='2%'></td> <td align='center' width='16%' height='21'>FILE TYPE</td> </tr> <?php for ( $i = 1; $i <= sizeof ( $return ); $i++ ) { echo " <tr> <td align='center' width='4%' height='21'>" . ( $i < 10 ? '0' . $i : $i ) . "</td> <td width='2%'></td> <td align='center' width='52%' height='21'>" . $return[$i]['name'] . "</td> <td width='2%'></td> <td align='center' width='24%' height='21'>" . $return[$i]['size'] . " bytes</td> <td width='2%'></td> <td align='center' width='16%' height='21'>" . $return[$i]['type'] . "</td> </tr> "; } ?> </table> </td> </tr> <tr> <td width='100%' height='8'></td> </tr> </table> </div> <a href="javascript:history.back()"><< Go Back</a> </body> </html> thankyou to anyone that can assist me with this I would really apreciate it basicly all I need to be shown is how i can call the comments aray from the previous forum
  7. Hi , I need a little bit of help tidying up the bellow search script, it does the search and returns the results perfectly however I wanted to make one expantion to it , I would like to make it so that it only displays a certain number of results per page , ( say 15 ) and over that number it gives a link to move onto the next 15 results . with the size of my tutorial system at the moment it isn't effecting me too badly but as it grows it will and i plan to have the content people working on it in a week or two anyways here is the code i have so far <html> <head> <title></title> </head> <body> <div class="search_bar"> <table><tr><td> <form name="form" action="search.php" method="Get"> <input class="whitebox" type="text" size="21" name="q" /></td><td class="go_button"> <input type="image" height="21px" src="./images/go.gif" name="Submit" /> </form></td></tr></table> </div> <?php $var = @$_GET['q'] ; $q=$_GET['q']; //Connect To database include "connect.php"; //collects Data $data=mysql_query(" SELECT t_id,t_notes,t_name,img FROM table WHERE file LIKE '%$q%' ") or die(mysql_error()); Print "<br><br><table class='print_list_alpha';>" ; while ($info= mysql_fetch_array($data) ) { Print "<tr class='result_row'><td><img src=./uploads/mini_thumbs/".$info['img']."></td><td class='result_col'><table><tr><td><a href=../tutorial.php?id=".$info['t_id']."><b>".$info['t_name']."</b></a></td><tr><td><p>"; Print substr($info['t_notes'],0,350); Print "<a href=../tutorial.php?id=".$info['t_id']."><b>.....</b></a></p></td></tr></table>"; } Print "</table>" ; ?> </body> </html> If someone could show me how to edit this or point me in the direction of a relevant guide ect I would be greatly appreciative. thankyou very much in advance regards, fallen_angel
  8. Hi , I have made a form where I have a few area's that contain drop down options the last option in the drop box is an other option , what I want to do is have a text box appear when other is selected. I belive i am on my way with the code bellow however there is something wrong with how I did the seccond dropdown ( or junction not sure wich ) if somone could please have a look at this and tell me what i have missed or done wrong I woudl really apreaciate it , the top drop down works pretty much as it's suposed to ( drops down a line instead of apearing next to the drop down ) however the seccond other box is always there and never hides itself the first ( workign ) function is if(document.all && !document.getElementById) { //IE4 support document.getElementById = function(id) { return document.all[id]; } } /* This works in Firefox, Netscape 6+, IE4+/Win, Opera 7+, Konqueror 3, Safari, IE5/Mac, and iCab 3. */ function customOption(selected) { //selected is the selected option if(!document.getElementById) return; // selected's value property is retrieved and converted to lower case to make // comparing it to another string simpler var val = selected.value.toLowerCase(); // gets the object reference for the element var el = document.getElementById('other1label'); // if val is set to 'customoption' show the textbox if(val == 'customoption') { el.style.display='block'; } else { // otherwise hide it or keep it hidden. el.style.display='none'; } } function dss_addLoadEvent(fn) { if(typeof(fn)!="function")return; var tempFunc=window.onload; window.onload=function() { if(typeof(tempFunc)=="function")tempFunc(); fn(); } } dss_addLoadEvent(function() { // we find the form element and the select element and attach the event // handlers to them var f = document.StrainReport; f.onsubmit = function(){return false;} var sel = f.medium_type; sel.onchange=function(){customOption(this.options[this.selectedIndex])} // we call the function when the page loads to hide #other1label initially sel.onchange(); }); // --> and the box that corrasponds with that working function has the following code <label> <div class="cont"> <div class="label"><label for="medium_type" ><select name="medium_type" id="select1"> <option name="medium_type" value="General Soil">General Soil</option> <option name="medium_type" value="Option 1">Option 1</option> <option name="medium_type" value="Option 2">Option 2</option> <option name="medium_type" value="Option 3">Option 3</option> <option name="medium_type" value="Option 4">Option 4</option> <option name="medium_type" value="Option 5 ">Option 5 </option> <option value="customoption">Other...</option> </select></label></div> <div class="label" id="other1label"><label for="other1" >Other: <input type="text" name="other1" id="other1"></label></div> </div> the seccodn funtion which doesn't work is if(document.all && !document.getElementById) { //IE4 support document.getElementById = function(id) { return document.all[id]; } } /* This works in Firefox, Netscape 6+, IE4+/Win, Opera 7+, Konqueror 3, Safari, IE5/Mac, and iCab 3. */ function customOption2(selected) { //selected is the selected option if(!document.getElementById) return; // selected's value property is retrieved and converted to lower case to make // comparing it to another string simpler var val = selected.value.toLowerCase(); // gets the object reference for the element var el = document.getElementById('other2label'); // if val is set to 'customoption2' show the textbox if(val == 'customoption2') { el.style.display='block'; }else { // otherwise hide it or keep it hidden. el.style.display='none'; } } function dss_addLoadEvent2 (fn) { if(typeof(fn)!="function")return; var tempFunc=window.onload; window.onload=function() { if(typeof(tempFunc)=="function")tempFunc(); fn(); } } dss_addLoadEvent2(function() { // we find the form element and the select element and attach the event // handlers to them var f = document.StrainReport; f.onsubmit = function(){return false;} var sel = f.system_type; sel.onchange=function(){(this.options[this.selectedIndex])} // we call the function when the page loads to hide #other2label initially sel.onchange(); }); // --> with the drop box code of <label> <div class="cont" <div class="label"><label for="system_type"><select name="system_type" id="select2"> <option name="system_type" value="Option 1">Option 1</option> <option name="system_type" value="Option 2">Option 2</option> <option name="system_type" value="Option 3">Option 3</option> <option name="system_type" value="Option 4">Option 4</option> <option name="system_type" value="Option 5 ">Option 5 </option> <option value="customoption2" onselect="customOption2(selected)">Other...</option> </select></label></div> <div class="label" id="other2label"> <label for="other1" > Other: <input type="text" name="other1" id="other1"></label></div> </div> I have been over and over the script and can't see what i'm doign wrong would really apreaciate any help peopel can provide I have attached a copy of the full page so that you can easly look at the two together thankyou again in advance to anyone that can help [attachment deleted by admin]
  9. Thanx for picking up on the error but it seems to be working the same way still doing that , However after being given a bit more time I have come up with the bellow code that checks for the cookie itself first and then echo's what it's supposed to if the user is not logged in , and ofcourse once they login it all works fine already so thats not a problem either If somone could please have a look at what i have now though and see if I have bloated it a bit too much or if they can advise of weaknesses in doing my checking this way I would really appreciate it think I have it but could you guys have a look and see if I am beign a bit sloppy or doing anything un needed here please <?php include "connect2.php"; if (isset($_COOKIE['session_id'])) { $mid = intval($_COOKIE['member_id']); $ses = intval($_COOKIE['session_id']); // Look up member $result = mysql_query("SELECT m.id, members_display_name, member_login_key, mgroup_others, g.g_access_cp FROM ibf_members m, ibf_groups g WHERE id = $mid AND m.mgroup = g.g_id"); $member = mysql_fetch_array($result); // Look up session $result2 = mysql_query("SELECT id,member_name,member_id FROM ibf_sessions WHERE member_id= $mid AND id = $ses"); $member2 = mysql_fetch_array($result2); // Name/password matches? if (($member['id'] == $mid) and ($member['member_login_key'] == $_COOKIE['pass_hash'])) { echo "<div class='welcome'>Welcome ".$member['members_display_name']."</div><br />"; return true; } else { echo "<div class='loginmessage'>Welcome Guest.</div><br />"; } } else { echo "<div class='loginmessage'>Welcome Guest.</div><br />"; } ?> thanx again to anyone in advance
  10. Hi , I am making a web app tutorial system and was hoping someone could help me out with a flaw in my session check code because it is doing something very strange. Before i go any further I should say that this session check is to check an invision session I have Invision 2.2 on my localhost where I am building the webapp so that could be related to the issue although I don't think it is i thought it was worth a mention . anyways first the code <?php include "connect.php"; $mid = intval($_COOKIE['member_id']); // Look up member $result = mysql_query("SELECT m.id, members_display_name, member_login_key, mgroup_others, g.g_access_cp FROM ibf_members m, ibf_groups g WHERE id = $mid AND m.mgroup = g.g_id"); $member = mysql_fetch_array($result); // Name/password matches? if (($member['id'] == $mid) and ($member['member_login_key'] == $_COOKIE['pass_hash'])) { echo "<div class='welcome'>Welcome ".$member['members_display_name']."</div><br />"; return true; } else { echo "<div class='loginmessage'>Welcome Guest.</div><br />"; } ?> Anyways onto explaining whats happening, I by default clear all cookies when i close off my browser and when I open a fresh copy of a page that is supposed to do a session check it doesn't seem to work , the bellow code is basically supposed to do a session check and then eighther echo , Welcome (username ) if a forum user is logged in , or it is supposed to echo Welcome Guest , Instead though for some unknown reason it just echo's Welcome. However and this is where it gets weird , if I log into my dev version of invision and then go back to the same page it works fine for logged in members and echo's Welcome (Username). So i figured it must be the else part of the statement , but before i fiddled with it i decided to try and use the Delete cookies set by this board function. when I used that function and then went back to my webapp , it echoed Welcome Guest as it should !! Closed my browser and it went back to not working again until I repeat the above steps If someone could tell me what they think is happening here and how to fix it I would really appreciate it
  11. Hi thanx for the reply what I am actually trying to do is que up a series of images , to be used in a slide show the webapp I have made is a tutorial guide and I want the users to be able to click on a link in the tutorial and view a slide show for all the images relating to it , I want to display these one by one thanx again for the help
  12. thanx allot guys  the as statement was where i was totally going wrong , I saw it used in the php manual and  I now have it so that I get no errors with the bellow code [code]<?php //Connect To database include "connect.php"; $id = $_GET['id']; //collects Data $data=mysql_query(" SELECT imagefile FROM strain_images where strain_id='$id' ") or die(mysql_error()); $row=mysql_fetch_array($data) ; $i=0 ; foreach ($row as $image) {   $i++ ;   $image[$i]=$row[$i]['imagefile'];   }   echo "<img src='./uploads/$image[0]'>" ?> [/code] however I think I am a little confused as to how the value gets echoed or mabey i set something wrong ( perhaps how i used as )  because when I do what i would normally do to insert an array into a database or echo it on the screen it simply doesn't work the above code for example gives me the letter b as the value of $image[0] which is not what it's database value is ,  if I change the 0 int to 1 though then I get a instead of b any idea's ? thanx again in advance
  13. I was trying to do what was suggested in the bellow link [url=http://www.phpfreaks.com/forums/index.php/topic,123109.msg508469.html#msg508469]http://www.phpfreaks.com/forums/index.php/topic,123109.msg508469.html#msg508469[/url] basicly the end result is that I want to create a slide show , the array is meant to contain each imagefile name from each relevant row , the above code is basicly just to change $i from 0 to what ever number, incrementing one number relivant per row  for example the first would become image[0]  would be the first , image[1] woudl be the seccond and image[8] would be the final hope that makes sense
  14. you could use get instead of post then at the top of the page have  something like [code]$id = $_GET['id'];[/code] then the variable is set in the url , for example for january you could have www.yoursite.com/page.php?id=january hope that helps
  15. sorry i must have been editing as you posted the error I am getting is unexpected T_VARIABLE on line 14
  16. I have been fiddling with the bellow for each statement for a few days now and just can't see what i'm getting wrong the purpose of this part of the script is to simply make the value of $i in the array go up from 0 to the max number of results [code]<?php //Connect To database include "connect.php"; $id = $_GET['id']; //collects Data $data=mysql_query(" SELECT imagefile FROM database where id='$id' ") or die(mysql_error()); $row=mysql_fetch_array($data) ; $i=0 ; foreach ($row { $i++   $image[$i]=$row[$i]['imagefile'] ;   } ) ?>[/code] when I say that i cant work it out i mean that i keep getting syntax errors for the most part they have been unexpected T_VARIABLE  errors however a few times they have been various other errors cause i have tried things out The part that is giving me trouble is the for each statement itself none of the other stuff there thanx allot to anyone that can help in advance
  17. thankyou very much for your assistance  i was able to achieve what i want to with your help :)
  18.   Hi ,   I have a question that follows on from a topic I had here a bit under a month or so about creating a next and previous button based on database values  I got that part sorted fine and it works well , however I want to tidy up the script by making it recognize the first and last tutorial so that it doesn't Display a back button for the first tutorial and so that it doesn't show a next button if there is no next row is there a way that I can do this ? the topic I started a while ago can be found  in this link [url=http://www.phpfreaks.com/forums/index.php/topic,122913.msg508473.html#msg508473]http://www.phpfreaks.com/forums/index.php/topic,122913.msg508473.html#msg508473[/url] I had a few lines of thought as to what i could do but am not sure eighter is the best way to do it First I was thinking of trying an if statement using isset however I have only had experiance doing that with submitted forms , and am not sure how to use it in this case the second idea I had  was to do a count of the rows in a second statement and if the tutorial id matched that number use an if statement to not show the appropriate button  the third idea i had will only work for the back option but at least it should do that ,and that was to have an if statement saying that if the tutorial id was equal to 1 then it doesn't show the back button Will any of these ideas work to achieve what i need ?  or can anyone help with a solution that is better than any of the above idea's
  19. Thank you both very much for your help , I have come down with the flu so have not been able to get to my machine for a few days , Will give the suggestion a shot and let you know how I go with it :) thank you very much again for your assistance
  20. Ok so I have this working except I can see a small issue that I'm not sure if I can fix or not , so thought I shoudl ask here once they get to the final existing reccord they can still click next tutorial and get a blank layout page that would normally be populated with info , Is there a way for me to have a default error page for if there is no information in the database that matches the search they get that instead of a blank layout page, the main reason beign that they can just click over and over and never find anythgin which could be confusing to some  or is it even possible to make it so that the final row doesn't show the next tutorial link ?
  21. Hi , I need to make a script that basicly operates like a slide show for my FAQ web app I guess I should give a little back ground first , I am creating a faq web app and the members are able to upload up to 8 images to be used in their tutorial, these images are uploaded to an uplaods folder and a row is writen in the database with the uploads name. makign it easy to keep track of. at the moment the images they upload come up in one strip with a slidding bar to move across it however I wanted to also add a feture that would allow the members to see the images from any one tutorial in a slide show SO basicly what I need it to do it query the database and find all the relivant images ( that part I'm all clear with )  I then want these images to be viewable through a slideshow should the member wish to do so I am fine will pulling the relivant reccord from the database however what I don't know how to do though is que up the images to be shown one after the other , the only way I can figure out how to do it , is by having the page refresh every 10 secconds and with each refresh it pulls a random row that is relivant to that tutorial , the only thing that worries me abotu that is that they are not nesseceraly goin to view all the images and they ae likely to get at least one duplicate row pulled out If someone coudl point me in the right direction as to what I shoudl be lookign into to figure this out I would really apreciate it  .  even some correct terminoligy for what i need would be fantastic so that i could search google for info regards,  and thankyou in advance Fallen_ angel
  22. yep I had tried it however after posting it I relised that in my dev version I was missing the ;  at the end thankyou so much for your help
  23. Yes they are sequential numbers and I understand how to manually navigate to them via url what i am not sure of is how to make the two links  for next and previous on the fly each time a page is loaded , would something like the bellow work or am i on the righ track ? [code]$previous=$info['id'] - 1 ;  $next=$info['id'] + 1  ;  [/code]
  24. Hi , I am building a FAQ system , everything has come together nicely and now I'm just trying to add a few more usability features to it , the thinhg in particular that i need assistance with is a link to move to the previous reccord and also the next reccord of the database , that way te users can flick through the guides without having to go back to the main menu the pages themselfs are accessed by going to www.domain.com/mainpage.php?id='faq-id' How would i go about creating the links to go back one reccord or forward one reccord as this obiosly has to change with the faq being viewed Thanx allot to anyone that can assist me
  25. Hi, I need to run two different functions as an html form is submitted  the format I have been trying to set it up with is [code] <form enctype="multipart/form-data" name="StrainReport" method="post" onsubmit="html2entities(this.pheno_notes,this.add_comments,this.image_comments2,this.image_comments1)" onsubmit="return validate_form(this)" action="submit_report.php">     [/code] the above code ofcourse runs the first function but it skips the seccond OnSubmit , I have tried [code] <form enctype="multipart/form-data" name="StrainReport" method="post" onsubmit="if return validate_form(this) then html2entities(this.notes,this.add_comments,this.image_comments2,this.image_comments1)" onsubmit="" action="submit_report.php"> [/code] What is it that I am doing wrong or have i totally got the wrong idea on how to do this ? thanx to anyone that can help me get this working
×
×
  • 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.