Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by paulonline2501

  1. Hi, this is not my code but its giving me trouble on a site. the code works in IE. but in Crome there is a radio button that is defaulted to not show some text. when the user switches to the other radio button (three are just two) the text is supposed to display. it works in IE but not Crome. is the text below enough or do you want to see the code for the whole page? <script type="text/javascript">$(document).ready(function() { $("input:radio[alt-id='test-hide']").change(function() { if(this.checked && this.value == "Y") {$("div#other-questions").show();}if(t
  2. elseif(htmlentities($db_oregion)==htmlentities("North & Islands")){echo("North, Highlands & Islands");} switch ($db_oregion) { case "Central": echo "Central Scotland"; break; case "East": echo "East Anglia"; break; case "Mid": echo "Mid & West Wales"; break; case "North": echo "North Wales"; break; case "North & Islands": echo "North, Highlands & Islands"; break; default: echo "$db_oregion";} thanks for all the replies. I tried using htmlentities [see above], and switch [see above] but neither worked. I w
  3. paulonline2501

    php if else

    hi everyone, I'm having trouble with a PHP if statement. I'm getting a value back from a database. the values stored in the DB aren't exactly what I want to display so im going to do a inline conversion on them. I want to say for example: if the region = 'central' then display 'central Scotland'. ive added my conversion but the value that is stored in the DB is showing rather than the converted value. can anyone spot what is wrong? UPDATE: OK, so it works for all of these apart from the "North & Islands" one. all othere convert, but this one doesn't. it doesn't change to
  4. ....actually, I think ive got it working but i'm sure there is a way to write it in a more elegant way.here's what I wrote: <?php $myString = trim($myString, ","); $myArray = explode(",", $myString); echo("<p>Exploded string in array:</p><ul>"); foreach($myArray as $thisValue) { $i=0; $thisPartsValueID=""; $thisPartsValueQuantity=""; $myArrayParts = explode("-", $thisValue); foreach($myArrayParts as $thisPartsValue) { if($i==0){echo("<li>id=".$thisPartsValue."</li>");$thisPartsValueID=$thisPartsValue;$i++;} else{echo("<li>quantity=".$thisPartsV
  5. yeah, thanks justsomeguy, but how do you get it into the sub array?
  6. <p><?php$myString = "45-2,34-2,35-1,";echo($myString);?></p><?php$myString = trim($myString, ",");$myArray = explode(",", $myString);echo("<p>Exploded string in array:</p><ul>");foreach($myArray as $thisValue){ echo("<li>".$thisValue."</li>");}echo("</ul>");?> I got the first explode working but struggling with the 2nd explode.
  7. ...thanks justsomeguy. yeah, I found something on exploding and am trying it now. I've got the first explode working, and even managed to trim the trailing comma to stop it from being put in the array.
  8. hi, I've got a variable being passed to me from a third party website. in the following format "45-1," where 45 would be the item id and 1 would be the quantity. the variable could hold a few key pairs. eg: "45-1,46-3,5-3,"the first number is always the item id and the 2nd number is always the quantity. each pair separated by a comma. there is always a trailing comma. I need to deconstruct these pairs and deduct the quantity from the correct item in the products table in my database. My question is, what is the best way to deconstruct these pairs?im guessing I should put these in to an array.n
  9. I got it working with the following code but if you have any improvements let me know. This code will always display the folder as empty. Opps.... foreach (glob('../../_documents/*.*',GLOB_NOCHECK) as $file){ $fileName = basename($file); if ($fileName = '*.*'){echo("<li>There are currently no files in this folder.</li>");break;} if ($fileName != 'index.php') {?> <li><?php echo"$fileName"?></li> <?php }//end if}//end foreach
  10. Hi, Does any one know how to display a message instead of the warning error when there are no files in the folder you are doing a directory list of? I have the following code, which produces a list of files in the folder. The only problem is when the folder is empty. I get a foreach error only when there are no files in the folder. I can forsee that sometimes the folders will be empty so will want to show my own error instead of this server warning. I think the "GLOB_NOCHECK" function may help but this may actually only work with folders rather than files. The code that w
  11. I'm trying to set the quantity of an item in an HTML Paypal button. I'm creating the buttons dynamically using a HTML template and values from my products table in my database [php/mysql]. I know you can set the quantity of an an item in the paypal buttons you can make on the the paypal website, but I want to make the buttons dynamically and avoid this step. I have generated the rest of the button without problem - they currently have name, price, postage etc. The one thing I can't do is set the quantity of the item. So the problem at the moment is, I have a lot of one off items. I want t
  12. hi Foxy, if i put: $x = glob('../../_docs/*.*');var_dump($x); the result is: bool(false)
  13. hi everyone, i've got a script that works on one website, that lists files in a directory. ive moved the script to another website but now the script isnt working. the script: <ul><?php foreach (glob('../../_docs/*.*') as $file){ $file = basename($file); if ($file != 'index.php') {?> <li><?php echo"$file"?> <a href="../../_docs/<?php echo"$file"?>" target="_blank">[View]</a> <a href="../products/delete/?id=<?php echo"$file"?>">[Delete]</a></br> URL: http://xxxxxxxx.com/CYC/_docs/<?php
  14. hahahhahahahhahahhahahahhahahahhahahhahhahahahaha thanks Foxy Mod!
  15. hi , I think ive got a syntax error or something. my query is running from a php page and for some reason the insert doesn't work when I add the last_updated column. I want it to record the date and time but its just giving this error: error: Error in query!You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'last_updated = NOW() WHERE id='57'' at line 11 the code: // open connection $UpdateConnection = mysql_connect($all_host, $all_user, $all_pass) or die ("Unable to connect!"); // select data
  16. sorry!!! i spotted the problem: my elseif is referencing the wrong variable: clean_hostDir_step03 it should be $clean_folder_step03 opps!!
  17. hi everyone, im having a problem spotting whats wrong with this code. what im doing is checking some input from a user of type 'folder'. if its got slashes on the front i remove. if its got slashes on the end i remove. and add one slash. it works up to here. then i check to see if the actually input a value for folder. they dont have to. in this case the value will just be '/'. as i added the slash eailier. if i leave folder blank this works too. if i input something i get a fail. i dont beleive the pregmatch is failing as i've used the same pregmatch on other types o
  18. hi, i have a preg_match that checks "descriptions". the preg_match fails when i input an apostrophe ' in the text box. my code is as follows: $clean_description_step01 = htmlentities($thisValue, ENT_QUOTES);$clean_description_step02 = stripslashes($clean_description_step01); if(preg_match("/^[-',.a-z0-9dws]{1,200}$/i",$clean_description_step02)) { do something here...} can any one see why its not working?
  19. Yeah thanks justseguy.As you said, I already have a login. This sets SESSION variables to logged in and sets the user id - I didn't really mention it before because its so obvious to me. I think this with the SQL check that I posted previously ill be able to check as you have just suggested. I think I'll go a step further and instead of using the id ill set up a token comprising id, ftp_id and random string and use that in the 'get'. That would add a level of complexity that would mean guessing the URL would be time consuming and a SESSION hack would have to be done.
  20. Actual thescientist I see what you mean now. I can simply say something like Select * from user_ftps where id = $_get[id]and user_id = SESSION[user_id]So simply when u think about it.Thanks a lot both of you
  21. The problem is that it is the id of an FTP. There are numerous users all with there own FTPs. Therefore it would be a easy for a user to change the URL to the id of an FTP that doesn't belong to them and see the details. This most be a very common issue. You have items in your database. You have a page that shows the details of this item using a parameter such as id to indicate the specific item. And the need to restrict viewing access based on the user having ownership of the item.
  • Create New...