Jump to content

dc_jt

Members
  • Posts

    290
  • Joined

  • Last visited

    Never

Posts posted by dc_jt

  1. If I had to take a random guess, it would be the Expires line. I would remove that header and see if it makes a difference.

     

    Thanks for the guess, I have tried that already but had no luck! Really dont know why it is doing it in IE. Does anyone have a script which they know definitely keeps the session data in IE??

  2. Ive got the following code which works fine in firefox, however in IE the file opens fine but for some reason it clears my session so once a user has downloaded the file, it logs them out the system.

     

    Does anyone know whats causing IE to clear the session?

     

    header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($oDoc->document_name));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: private');
        header('Pragma: private');
        header('Content-Length: ' . filesize($sUrl));
        
        ob_clean();
        flush();
        readfile($sUrl);
        exit;

  3. Hi I am fairly new to using cookies, therefore I would like some help...

     

    I have users that come to my site to fill in a form via specific urls. I.e http://www.site.com/test and http://www.site.com/test2 etc. This will determine who they are associated to. I.e test or test2

    Depending on what url they come through I need to set a cookie so that even if they dont come via this url in the future i.e they just go straight to the site through http://www.site.com and then click the form page, I can still associate them from where they came from previously.

     

    What would be the best way to set the cookie and then check in the future that one is set?

     

    Im guessing to set it would be something like:

    $value = "test". (Or "test2" depending on the url)

     setcookie('associate', '$value', time()+86400*365, '/'); #expire in a year

     

    And then to retrieve it would be

    $_COOKIE['associate']

    . Is this correct?

     

    Thanks for your help.

  4. It depends on what DBMS you are using. There is the mysql_real_escape_string function for MySQL. The MySQLi and PDO extensions support something called prepared statements, which I personally prefer.

     

    Thanks for the reply, I am using PhpMyAdmin. So I would basically do the following before inserting into the database?

     

    $_POST = mysql_real_escape_string($_POST)

     

    Also, I am using TinyMCE on some fields, does this make any difference or not?

  5. Hi I am using php and I am looking at the best way to insert into a database and then echo out again in the correct format. I.e Im particularly talking about when adding apostrophes etc. I am also not using magic quotes (as I believe this will be discontinued in PHP6 and my current server has it disabled. I know I can enable it but Im trying to think ahead). Do I remove slashes, add slashes or something else? Ideally I would like to be able to simply echo out the result like <?=$aResult['description']?> without having to add any formatting everytime I echo out.

     

    Therefore if I entered "Test test's "test"" for example into a field, what should I do to this before I insert it into the database in order to get the correct format when I output it?

     

    Hope that makes sense.

     

    Thanks

  6. Whats the best way to check two dates against a date in a mysql format. I.e

     

    I have many dates in this format 0000-00-00 00:00:00

     

    I then pick two dates e.g 20/04/2009 and 2/05/2009. I want to find all dates between these two dates. What is the best way to do this? I presume I need to change the format, do I change them into the same format as the first date (0000-00-00 00:00:00 ) or do I change them all into another format i.e using strtotime/timestamp?

     

    Thanks

  7. Hi

     

    Just after a bit of advise really. I need to code a flow chart which will begin with one question and if the user answers yes then another question will appear, if they answer no then they cant go any further etc.

     

    What would be the best way to do this? I was thinking of creating a form which starts with a hidden mode of 1. If this is set to 1 then it only shows the first question. Once the answer has been submitted, if it is correct then they are returned to the form but the mode is 2, then I will check the mode and if its 2 then question 1 and 2 can be displayed etc etc for each question. Is this a good way of doing it or is there a better way? My other alternative was using javascript but I think this may take too long? Any suggestions?

     

    Thanks

  8. Thanks for your help. I have never really used indexes to be honest but I have just tried adding an index to the job_id field and the date_added. This is because the query I am running selects all users where job_id equals the id passed in and the date_added is between the two dates passed in.

     

    I simply just clicked on "index" next to the two fields, is that all that is needed because it still doesnt seem to work?

     

     

     

  9. Ive created a script so that gets all users from my database by two dates and loops through them then downloads this as a csv. This is how its done (the main part anyway)@

    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=users.csv");
    header("Pragma: no-cache");
    header("Expires: 0");
    
    $aUsers = $oTblUsers->getUsers($startdate, $enddate);
    
    $date=date('Y')."-".date('m')."-".date('d');
    
    header('Pragma: ');
    header('Cache-control: ');
    header("Content-type: application/force-download");
    header("Content-disposition: attachment; filename=".$date."competition_entries.csv");
    
    $top = 'Title, First Name, Surname, Address 1, Address 2, City, Email Address, Date of Birth, Telephone Number, Mobile Number, Postcode, Date Added';
    echo ($top);
    echo("\n");
    
    if($aUsers)
       foreach ($aUsers as $aItem){
    
    	echo ('"'.$aItem[title].'",');	
    	echo ('"'.$aItem[name].'",');	
    	echo ('"'.$aItem[surname].'",');
    	echo ('"'.$aItem[address1].'",');
    	echo ('"'.$aItem[address2].'",');
    	echo ('"'.$aItem[city].'",');
    	echo ('"'.$aItem[email].'",');
    	echo ('"'.$aItem[date_of_birth].'",');
    	echo ('"'.$aItem[telephone].'",');
    	echo ('"'.$aItem[mobile].'",');
    	echo ('"'.$aItem[postcode].'",');
    	echo ('"'.$sDateAdded.'",');
    	echo("\n");
    
    
    }
    
    

     

    Now this has been working however I noticed today that if I put 5/10/2008 in until the 1/1/2009 then it doesnt work and in Chrome I get a message saying page not found. In Firefox it doesnt do anything at all. If I do it from the 6/10/2008 to the 1/1/2009 then it works, however there is over 16,000 records and is almost 3mb in size.

     

    Is this why it wont work because the filesize or amount of records is too much? What can I do?

     

    Thanks

     

     

  10. You can try converting the tables to utf8_bin... Also make sure you are using a UTF8 connection, this provides the broadest range of character support.

     

    Thanks but im not quite sure how I would do this? Would I have to re-import the data? Is there anyway I can simply encode the characters on the front end when I echo it out?

  11. Hi

     

    I have recently imported a lot of data into my database, however a lot of the content contains characters such as � and ¿½ etc. These seem to be the apostrophes and speech marks. I have tried using a str_replace to replace them with the correct html for an apostrophe or a speech mark but it doesnt seem to work. Any ideas what I can do?

     

    Thanks

  12. Hi I am using phpThumb, however for example, I would like my image to be 100hx100w so I have done the following:

     

    $max_w = 100;
    $max_h = 100;
    
    $url = phpThumbURL('src='.$pic.'&w='.$max_w.'&h='.$max_h);
         
    echo "<img src=\"$url\">";
    

     

    However, it is resizing the image to 100 x 75! Any idea why this is? I want to set the exact dimensions.

     

    Thanks

  13. Ive tried searching for this but still cant seem to get my page to refresh.

     

    Here is my setup.

     

    Page 1 contains the following link:

    <a href="#" style="cursor:pointer" onclick="MM_openBrWindow('/cms/_content/documents/upload-document.inc.php?iDocumentId=<?=$_GET['iDocumentId']?>&iCategoryId=<?=$_GET['iCategoryId']?>','cardimg','width=800,height=300')">Upload Document</a>

     

    This opens page 2 as a popup window.

     

    In page 2 I have the following to close the popup:

    <a onclick="JavaScript:refreshParent()" href="#">Close</a>

     

    And also have the following javascript within page 2:

    <script language="JavaScript">
    <!--
    function refreshParent() {
      window.opener.location.href = window.opener.location.href;
    
      if (window.opener.progressWindow)
    
    {
        window.opener.progressWindow.close()
      }
      window.close();
    }
    //-->
    </script>

     

    This closes the popup but doesnt refresh page 1, any ideas why??

     

    Thanks

     

     

     

     

  14. Hi

     

    Im having a lot of trouble trying to work out what sizes to re-size my images to. Basically I re-size my images on the fly, however they go into a gallery which has a frame of 628w x 432h.

     

    Now, what I'm struggling with is working out how best to fit each image into this frame.

     

    This is what I have so far but its still not correct:

     

    //loop through gallery
    <?php while ($aActualImage = mysql_fetch_array($rGallery)) {
              //if landscape image
               if ($aActualImage['image_width'] > $aActualImage['image_height']){
       // get width for template 9005 (628)
       $aSetlarge = _grabImageSize('9005',$aActualImage['image_width'],$aActualImage['image_height']);
    
    			//if max width is greater than the actual image width
    			if($aSetlarge['width'] 		> $aActualImage['image_width']){
    
    				$aSetlarge['width'] 	= $aActualImage['image_width'];
    				$aSetlarge['height'] 	= $aActualImage['image_height'];
    			} else {
    				$aSetlarge['width'] 	= $aSetlarge['width'];
    				$aSetlarge['height'] 	= $aSetlarge['height'];
    			}
    
    		//else if portrait image
    		} elseif ($aActualImage['image_height'] > $aActualImage['image_width']){
    			 get width for template 9006 (432)
    			$aSetlarge = _grabImageSize('9006',$aActualImage['image_width'],$aActualImage['image_height']);
    
    			//if max height is greater than actual image height
    			if($aSetlarge['height'] 	> $aActualImage['image_height']){
    
    				$aSetlarge['height'] 	= 	$aActualImage['image_height'];
    				$aSetlarge['width'] 	= 	$aActualImage['image_width'];
    			} else {
    				$aSetlarge['height'] 	=	$aSetlarge['height'];
    				$aSetlarge['width'] 	= 	$aSetlarge['width'];
    
    			}
    
    		//else if square
    		} else {
    			$aSetlarge = _grabImageSize('9004',$aActualImage['image_width'],$aActualImage['image_height']);
    
    			if($aActualImage['image_height'] > $aSetlarge['height']){
    				$aSetlarge['height'] 	= 	$aSetlarge['height'];
    				$aSetlarge['width'] 	= 	$aSetlarge['width'];
    			} else {
    				$aSetlarge['width'] 	= 	$aActualImage['image_width'];
    				$aSetlarge['height'] 	= 	$aSetlarge['height'];
    			}
    
    		}
    
    		$sSizelarge	=	$aSetlarge['width'].'x'.$aSetlarge['height'];		
    		//Set image size
    

     

    Can anyone see what Im missing? Most images seem fine, although on some, the height is too big for the frame.

     

    Once I have realised it is a landscape, portrait or square would I then find out if the actual image width is greater than the frame width and also check if the actual image height is greater than the frame height? Im so confused now!!

     

    Anyhelp would be greatly appreciated.

     

    Thanks

  15. Update :

    I now have the following which works, although when I click on a project it only shows that project and not all projects for that category in the nav.

     

    Any ideas of how I can change this to still show all projects for the category. I know its because Ive put

    ($url == '/projects/centre.php?iCentresId='.$oCentresArticle->centres_id

    but I dont know how else to do it?

     

    Thanks

     

    <li><a href="/projects/" accesskey="N">Our Projects</a>
            <?php if($file == 'projects'){?>
            <ul>
    
            <?php
    			while ($oCategories = mysql_fetch_object($rCategories))
    			{?>
          	<li><a href="/projects/our-projects.php?iCategoryId=<?=$oCategories->category_id?>" accesskey="P"><?=$oCategories->category?></a>
            	
          	<?php 
                    	$rCentresArticles = $oTblCentres->GetArticles($iStart, 500, $oCategories->category_id);
    
                    	if($url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.'' || $file2 == '/projects/centre.php'){?>
          		
    
                    	<?php
                    	$iCount=0;
    				while ($oCentresArticle = mysql_fetch_object($rCentresArticles))
    				{?>
    				<?php if($url == '/projects/centre.php?iCentresId='.$oCentresArticle->centres_id || $url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.''){?>
    				<? 
    				$iCount++;
    				if ($iCount == '1'){
    					echo "<ul>";
    				}?>
    				<li><a href="/projects/centre.php?iCentresId=<?=$oCentresArticle->centres_id ?>"><?=$oCentresArticle->title?></a></li>
    				<?php }?>
    				<?php }?>
    				<? if ($iCount >= '1'){
    					echo "</ul>";	
    				}?>
    
            	<?php }?>
    
            </li>
            <?php }?>
            </ul>
            <?php }?>
            
            </li>

  16. Hi Ive got a navigation which has 3 tiers. I want to show certain tiers depending on what page I am on.

     

    1. Our Projects

              Category Name

                      Project Name

              Category Two Name

                      Project Two Name

                      Project Three Name

     

    etc etc...

     

    The idea is that at first only 'Our Projects' is shown.

     

    When you click this and go to the /projects/ page, the 'Category Name' and 'Category Name Two' will appear.

     

    When you click a category e.g 'Category Name' this will take you to /projects/our-projects.php?iCategoryId=1 and the projects for this category will appear (in this case 'Project Name').

     

    When you click a project e.g. Project Name, you are taken to the projects/centre.php?iCentresId=1 page and the categories and projects for this category are still shown.

     

    The way I have done it works, however when I click the actual project, it hides the project in the dropdown.

     

    Hope all this makes sense, I have tried to describe as best as I could.

     

    Please see below for what Ive done so far.

     

    $d=explode("/",$_SERVER[sCRIPT_NAME]);
    $file=($d [1]);
    $file2 = ($_SERVER[sCRIPT_NAME]);
    $url = $_SERVER['REQUEST_URI'];
    
    <li><a href="/projects/" accesskey="N">Our Projects</a>
            <?php if($file == 'projects'){?>
            <ul>
    
            <?php
    			while ($oCategories = mysql_fetch_object($rCategories))
    			{?>
          	<li><a href="/projects/our-projects.php?iCategoryId=<?=$oCategories->category_id?>" accesskey="P"><?=$oCategories->category?></a>
            	
          	<?php 
                    	$rCentresArticles = $oTblCentres->GetArticles($iStart, 500, $oCategories->category_id);
                    	if($url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.''){?>
          			<ul>
    
                    	<?php
    				while ($oCentresArticle = mysql_fetch_object($rCentresArticles))
    				{
    					if($url == '/projects/centre.php?iCentresId='.$oCentresArticle->centres_id.'' || $url == '/projects/our-projects.php?iCategoryId='.$oCategories->category_id.''){?>
    				<li><a href="/projects/centre.php?iCentresId=<?=$oCentresArticle->centres_id ?>"><?=$oCentresArticle->title?></a></li>
    				<?php }?>
    				<?php }?>
            	</ul>
            	<?php }?>
            </li>
            <?php }?>
            </ul>
            <?php }?>
    

     

    Thanks

  17. Hi

     

    Im trying to submit two forms using one onclick function but it seems to be only submitting the 'delivery_address_details' form and not the payment_details form. However if I comment out the 'delivery_address_details' form then it does submit the other form.

     

    Please see my code below: Thanks

     

    
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function submitForms()
    {
    document.payment_details.submit();
    document.delivery_address_details.submit();
    }
    //-->
    </SCRIPT>
    
    <form name="delivery_address_details" action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
    
    <input type="hidden" name="checkout_mode" value="set_delivery" />
    <input type="hidden" name="mode" value="select_address" />
    <input type="hidden" name="address_id" value="0" />
    
    
    	<h2>Select an Address for Delivery</h2>
    
    	<?php 
    	$oTblUser = new RCLUser();
    	$oTblUserLogin = new RCLUserLogin($_SESSION['shop_user_id']);
    
    	$aDetails = $oTblUser->getUser($_SESSION['shop_user_id']);
    
    	if(sizeof($aDetails['delivery_addresses'])>0){
    		$address_count = 0;
      		foreach($aDetails['delivery_addresses'] as $address){
    
    	?>
    	<div class="row">
    
    	    <input name="delivery_address" class="" type="radio" value="<?=$address['user_info_id']?>" <? if($_SESSION['shop_user_delivery_address']==$address['user_info_id']){echo('checked');}?> />
    	    <?=$address['address'][1]?>,<?=$address['address'][2]?>,
    	    <? if($address['address'][3]){echo $address['address'][3].',';}?>
    	    <?=$address['city']?>
    	      <?=$address['postcode']?>
    
    	</div>
    	<? 	$address_count++;
      		}
      		}?>
    
    		<!--<a href="#" id="submit_button" onclick="document.delivery_address_details.submit();">Use Selected Address</a>-->
    
    
    </form>
    
    <form name="payment_details" action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">                  
    	<input type="hidden" name="checkout_mode" value="submit_payment" <?/*value="confirmation"*/?> />
    	<input type="hidden" name="mode" value="submit_payment" />
    
    <div class="step-col"><h2>Payment Details</h2>
    
                    <label for="startdate">Card Type</label>
                    <select name="CardType" id="cardtype" class="frmfield-dates">
                      <option value="" selected="selected">-- Select --</option>
    				          <option value="MC"<?=($_REQUEST['CardType'] == 'MC') ? ' SELECTED' : '' ?>>Mastercard</option>
    				          <option value="VISA"<?=($_REQUEST['CardType'] == 'VISA') ? ' SELECTED' : '' ?>>Visa</option>
    				          <option value="DELTA"<?=($_REQUEST['CardType'] == 'DELTA') ? ' SELECTED' : '' ?>>Visa Debit</option>
    				          <option value="UKE"<?=($_REQUEST['CardType'] == 'UKE') ? ' SELECTED' : '' ?>>Visa Electron</option>
    				          <? /*<option value="MAESTRO"<?=($_REQUEST['CardType'] == 'MAESTRO') ? ' SELECTED' : '' ?>>Maestro</option>*/?>
    				          <option value="SWITCH"<?=($_REQUEST['CardType'] == 'SWITCH') ? ' SELECTED' : '' ?>>Maestro</option>
    				          <option value="AMEX"<?=($_REQUEST['CardType'] == 'AMEX') ? ' SELECTED' : '' ?>>Amex</option>
    				          <option value="DELTA"<?=($_REQUEST['CardType'] == 'DELTA') ? ' SELECTED' : '' ?>>Delta</option>
    				        </select>
                	
                    <label for="cardholder">Name on Card</label>
                    <input name="CardHolder" type="text" id="cardholder" class="frmfield" value="<?=$_REQUEST[CardHolder]?>"/><br />
                    
                    <label for="cardnumber">Card Number</label>
                    <input name="CardNumber" type="text" id="cardnumber" class="frmfield" value="<?=$_REQUEST['CardNumber']?>" size="25"/><br />
                    
                    <label for="securitynumber">Security Number</label>
                    <input name="CV2" type="text" id="securitynumber" class="frmfield-small" value="<?=$_REQUEST[CV2]?>" size="3" maxlength="3"/>
                    
                    <a href="#"><img src="/assets/images/shop/help-ico.gif" alt="help" width="24" height="16" border="0" onclick="MM_openBrWindow('/creditcard-info.html','cardimg','width=400,height=310')" /></a><!--<span class="security-no-q">Where is this located?</span>--><br />
                    
                    
                    <label for="startdate">Start Date</label>
                    <select name="ccValM" id="validmonth" class="frmfield-dates">
                     <option value="" selected="selected">Month</option>
                	  <option <?=($_REQUEST['ccValM']=='01') ? 'selected' : '' ?>>01</option>
    					      <option <?=($_REQUEST['ccValM']=='02') ? 'selected' : '' ?>>02</option>
    					      <option <?=($_REQUEST['ccValM']=='03') ? 'selected' : '' ?>>03</option>
    					      <option <?=($_REQUEST['ccValM']=='04') ? 'selected' : '' ?>>04</option>
    					      <option <?=($_REQUEST['ccValM']=='05') ? 'selected' : '' ?>>05</option>
    					      <option <?=($_REQUEST['ccValM']=='06') ? 'selected' : '' ?>>06</option>
    					      <option <?=($_REQUEST['ccValM']=='07') ? 'selected' : '' ?>>07</option>
    					      <option <?=($_REQUEST['ccValM']=='08') ? 'selected' : '' ?>>08</option>
    					      <option <?=($_REQUEST['ccValM']=='09') ? 'selected' : '' ?>>09</option>
    					      <option <?=($_REQUEST['ccValM']=='10') ? 'selected' : '' ?>>10</option>
    					      <option <?=($_REQUEST['ccValM']=='11') ? 'selected' : '' ?>>11</option>
    					      <option <?=($_REQUEST['ccValM']=='12') ? 'selected' : '' ?>>12</option>
                	</select>
                	
                	<select name="ccValY" id="validyear" class="frmfield-dates">
                	   <option value="" selected="selected">Year</option>
    					      <? for($year=(date("Y")-5); $year<(date("Y")+1); $year++) { ?>
    					      <option <?=($_REQUEST['ccValY']==substr($year,-2,2)) ? 'selected' : '' ?>>
    					        <?=substr($year,-2,2)?>
    					      </option>
    					      <? }?>
    					    </select><br />
                    <label for="expirydate">Expiry Date</label>
                    <select name="ccExpM" id="expiresmonth1" class="frmfield-dates">
                    			 <option value="" selected="selected">Month</option>
                	 			 <option <?=($_REQUEST['ccExpM']=='01') ? 'selected' : '' ?>>01</option>
    					      <option <?=($_REQUEST['ccExpM']=='02') ? 'selected' : '' ?>>02</option>
    					      <option <?=($_REQUEST['ccExpM']=='03') ? 'selected' : '' ?>>03</option>
    					      <option <?=($_REQUEST['ccExpM']=='04') ? 'selected' : '' ?>>04</option>
    					      <option <?=($_REQUEST['ccExpM']=='05') ? 'selected' : '' ?>>05</option>
    					      <option <?=($_REQUEST['ccExpM']=='06') ? 'selected' : '' ?>>06</option>
    					      <option <?=($_REQUEST['ccExpM']=='07') ? 'selected' : '' ?>>07</option>
    					      <option <?=($_REQUEST['ccExpM']=='08') ? 'selected' : '' ?>>08</option>
    					      <option <?=($_REQUEST['ccExpM']=='09') ? 'selected' : '' ?>>09</option>
    					      <option <?=($_REQUEST['ccExpM']=='10') ? 'selected' : '' ?>>10</option>
    					      <option <?=($_REQUEST['ccExpM']=='11') ? 'selected' : '' ?>>11</option>
    					      <option <?=($_REQUEST['ccExpM']=='12') ? 'selected' : '' ?>>12</option>
                	</select>
                	<select name="ccExpY" id="expiresyear1" class="frmfield-dates">
                	  <option value="" selected="selected">Year</option>
    					      <? for($year=(date("Y")-5); $year<(date("Y")+5); $year++) { ?>
    					      <option <?=($_REQUEST['ccExpY']==substr($year,-2,2)) ? 'selected' : '' ?>>
    					        <?=substr($year,-2,2)?>
    					      </option>
    					      <? }?>
    					    </select><br />
                    <label for="issuenumber">Issue Number</label>
                    <input name="IssueNumber" type="text" id="issuenumber" class="frmfield-small" value="<?=$_REQUEST[issueNumber]?>"/><br />
                    
                  
                    
                    <a href="#" id="submit_button" onclick="submitForms()">Make Payment</a>
                    
                      </form>
    

  18. Im doing a shopping basket and Ive got an image which must only be displayed if $_SESSION['basket'][1475] is set or $_SESSION['basket'][1476] is set AND no other products are set in the session for example $_SESSION['basket'][1477], $_SESSION['basket'][1478], $_SESSION['basket'][1479] etc.

     

    Whats the best way to do this? I tried the following but it doesnt seem to work:

     

     if($_SESSION['store']['store_id'] || (isset($_SESSION['basket'][1475]) || (isset($_SESSION['basket'][1476]) && !isset($_SESSION['basket'][1468])))){?>	

     

    By the way I also need it to be shown if $_SESSION['store']['store_id'] is set.

     

    Hope this makes sense.

     

    Thanks

×
×
  • 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.