Jump to content

Help with Syntax


Go to solution Solved by Barand,

Recommended Posts

I have this code that I want to add a hyperlink to. The code works as is (this is obviously only part of it). The code is looking at the time stamp of the file and doing some calculations. I want to add the hyperlink to the code in red so the user can click on the linmk and open the file. The link in green is the path and file that would be in the hyperlink.

if(file_exists('\emwin\adm\cwfmob.txt')) {
         do_check("NWS Mobile - CWFMOB",'\emwin\adm\cwfmob.txt',60*60*60,'\emwin\adm\cwfmob.txt');

Link to comment
Share on other sites

Here's some code with and without the hyperlink. My confusion is where to use quotes and where to use ticks

if(file_exists('\emwin\adm\cwfmob.txt')) {
           do_check('<a href="\emwin\adm\cwfmob.txt' title="Coastal Water Forecast" target="_self">CWFMOB</a>','\emwin\adm\cwfmob.txt',60*60*60,'\emwin\adm\cwfmob.txt');
        
        

This code works assuming I enter the correct file paths


        if(file_exists('TRACReport.txt')) {
           do_check("Nexstorm TRACreport",'TRACReport.txt',10*60+15,'file');

Link to comment
Share on other sites

  • Solution

Ticks are only used in SQL queries around identifiers.

When using quotes (single or double) they should be in matching opening and closing pairs.

 do_check('<a href="\emwin\adm\cwfmob.txt' title="Coastal Water Forecast" target="_self">CWFMOB</a>','\emwin\adm\cwfmob.txt',60*60*60,'\emwin ...');
          ^..............................^       ^......................^        ^.....^           ^.^                     ^..........^
                   

As you can see, you href does not have matching opening and closing quotes, throwinng other pairs out of synch.

try

 do_check('<a href="\emwin\adm\cwfmob.txt" title="Coastal Water Forecast" target="_self">CWFMOB</a>','\emwin\adm\cwfmob.txt',60*60*60,'\emwin ...');
                   ^.....................^       ^......................^        ^.....^             
          ^........................................................................................^ ^.....................^          ^..........^

 

See https://www.php.net/manual/en/language.types.string.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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