close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Trying to change from old ADDT to MySQLi coding to show image if file exists in folder

Thread began 1/13/2020 8:00 am by Nixtev | Last modified 1/13/2020 4:06 pm by Ray Borduin | 62 views | 2 replies |

Nixtev

Trying to change from old ADDT to MySQLi coding to show image if file exists in folder

Hi, I'm trying to bring some old code up to date so have managed to sort out most of the code block but I can't quite get my head around the dynamic file name structure bit so can anyone help please?
Recordset is Rsi_pages and page_photo1 is the database field name where the image name is stored as it's created dynamically when the image is uploaded.
Obviously it has changed to $Rsi_pages->getColumnVal("page_photo1") in the new version but I'm getting a bit lost at how that carries over into the required line of code.
Alternatively, is there a better way to do this?


Old code

<?php
// Show If File Exists (photo1)
if (tNG_fileExists("uploads/images/pages/", "{Rs_pages.page_photo1}")) {
?>
<div align="center">
<img src="<?php echo tNG_showDynamicImage("", "uploads/images/pages/", "{Rs_pages.page_photo1}");?>" alt="<?php echo $row_Rs_pages['page_photo1_caption']; ?>" /><br />
<span class="photocapt"><?php echo $row_Rs_pages['page_photo1_caption']; ?></span>
</div>
<?php }
// EndIf File Exists (photo1)
?>

New Code

<?php
// Show If MySQLi File Exists (photo1)
if (fileExists("uploads/images/pages/", "{Rs_pages.page_photo1}")) { // <--- what do I change this line to?
?>
<div align="center">
<img src="uploads/images/pages/<?php echo($Rsi_pages->getColumnVal("page_photo1")); ?>" alt="<?php echo($Rsi_pages->getColumnVal("page_photo1_caption")); ?>" /><br />
<span class="photocapt"><?php echo($Rsi_pages->getColumnVal("page_photo1_caption")); ?></span>
</div>
<?php }
// EndIf MySQLi File Exists (photo1)
?>


Thanks

Sign in to reply to this post

Ray BorduinWebAssist

I'm not familiar with tNG_fileExists, however I think this would work:

if (tNG_fileExists("uploads/images/pages/", $Rsi_pages->getColumnVal("page_photo1")))

But I think it would also work with:

if (file_exists("uploads/images/pages/", $Rsi_pages->getColumnVal("page_photo1")))

Sign in to reply to this post
Did this help? Tips are appreciated...

Nixtev

Thanks, I've used option 2 as the tNG stuff is all part of ADDT so that's what I'm removing.
Tweaked slightly to
if (file_exists("uploads/images/pages/". $Rsi_pages->getColumnVal("page_photo1")))
and it now appears to do what's needed so thanks :)

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...