Jump to content

Can't access database from within PHP or Pages


不中用

Recommended Posts

Posted

.

I can't access the database in PHP nor in Pages .. I follow "kind of" the logic I see in the source files .. I am missing something here?

I want to retrieve the file version from a file in Downloads ..

 

<?php
require_once( 'init.php' );
\IPS\Session\Front::i();
$memCSRF = \IPS\Session::i()->csrfKey;
$member = \IPS\Member::loggedIn();
$memName = $member->name;
$memEmail = $member->email;
$memID = $member->member_id;
$fileVersion = \IPS\Db::i()->select( 'file_version', 'downloads_files', array( 'file_id=?', '8' ) ); 
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>testing page</title>
</head>

<body>

<p>Hello <?php echo $memName; ?></p>

<p>File version: <?php echo $fileVersion; ?></p>  

<p><a href="logout/?csrfKey=<?php echo $memCSRF; ?>">Logout</a></p>

</body>
</html>

the result I get is: (it should be a version number)

 

Hello IN10TION
File version: SELECT file_version FROM `downloads_files` WHERE file_id=?
Logout

 

In Pages I've tried:

{{$member = \IPS\Member::loggedIn();}}
{{$memName = $member->name;}}
{{$fileVersion = \IPS\Db::i()->select( 'file_version', 'downloads_files', array( 'file_id=?', '8'));}}
<strong>File $fileVersion</strong>

and I get also same result: (it should be a version number)

 

File SELECT file_version FROM `downloads_files` WHERE file_id=?

 

I can't find any solution in the forums, so I ask here ..

 

 

.

Posted
$fileVersion = \IPS\Db::i()->select( 'file_version', 'downloads_files', array( 'file_id=?', '8' ) ); 

should be: 

$fileVersion = \IPS\Db::i()->select( 'file_version', 'downloads_files', array( 'file_id=?', '8' ) )->first(); 

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...