
Fallen_angel
Members-
Posts
88 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Fallen_angel's Achievements

Member (2/5)
0
Reputation
-
Problem parsing variables in php include Please help
Fallen_angel replied to Fallen_angel's topic in PHP Coding Help
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 -
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
-
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
-
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
-
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
-
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
-
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
-
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]
-
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
-
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
-
Asistance debuging a For Each statement
Fallen_angel replied to Fallen_angel's topic in PHP Coding Help
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 -
Asistance debuging a For Each statement
Fallen_angel replied to Fallen_angel's topic in PHP Coding Help
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 -
Asistance debuging a For Each statement
Fallen_angel replied to Fallen_angel's topic in PHP Coding Help
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 -
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
-
Asistance debuging a For Each statement
Fallen_angel replied to Fallen_angel's topic in PHP Coding Help
sorry i must have been editing as you posted the error I am getting is unexpected T_VARIABLE on line 14