Bitcoin Forum
May 13, 2024, 12:26:52 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Cant pull RPC credentials from my config.php file  (Read 52 times)
The_Trader (OP)
Member
**
Offline Offline

Activity: 180
Merit: 52


View Profile
April 07, 2023, 01:07:37 PM
Merited by hugeblack (6)
 #1

Hi all

So I want to display several things on a webpage in php ie getbalance, getblockheight etc etc

This was fine and everything was displaying as I wanted it too, but I found I was typing a lot of the same stuff so thought I would create a config to pull the info in from, however I am having issues as it wont connect to the wallet now.

My config:

Code:
<?php

$rpc_user 
'xxxxxxxxx';
$rpc_pass 'xxxxxxxxxxxxxxxxxxxxxx';
$rpc_host 'localhost';
$rpc_port 'xxxxx';

?>


My webpage:

Code:
<?php
include('config.php')
require_once(
'easybitcoin.php');

$bitcoin = new Bitcoin('$rpc_user','$rpc_pass','$rpc_host','$rpc_port');

$getbalance $bitcoin->getbalance();

print_r($getbalance);

?>

The above is a snipet of the webpage but if I can solve this bit then I can solve the rest, the config file is in the correct directory (the same as the index page)
I know the easybitcoin works because if i replace the $rpc_user etc with the actual details its is fine.

Any help would be most welcome, I suspect it is something real easy, that I can no longer see as im stressed out over it Smiley

Thanks
TT

1715603212
Hero Member
*
Offline Offline

Posts: 1715603212

View Profile Personal Message (Offline)

Ignore
1715603212
Reply with quote  #2

1715603212
Report to moderator
1715603212
Hero Member
*
Offline Offline

Posts: 1715603212

View Profile Personal Message (Offline)

Ignore
1715603212
Reply with quote  #2

1715603212
Report to moderator
1715603212
Hero Member
*
Offline Offline

Posts: 1715603212

View Profile Personal Message (Offline)

Ignore
1715603212
Reply with quote  #2

1715603212
Report to moderator
Remember that Bitcoin is still beta software. Don't put all of your money into BTC!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715603212
Hero Member
*
Offline Offline

Posts: 1715603212

View Profile Personal Message (Offline)

Ignore
1715603212
Reply with quote  #2

1715603212
Report to moderator
1715603212
Hero Member
*
Offline Offline

Posts: 1715603212

View Profile Personal Message (Offline)

Ignore
1715603212
Reply with quote  #2

1715603212
Report to moderator
OmegaStarScream
Staff
Legendary
*
Offline Offline

Activity: 3472
Merit: 6133



View Profile
April 07, 2023, 01:13:19 PM
Merited by hugeblack (4)
 #2

I'm not that familiar with PHP so I could be wrong, but it looks like you're passing strings instead of variables here?:

Code:
$bitcoin = new Bitcoin('$rpc_user','$rpc_pass','$rpc_host','$rpc_port');

Instead, it should be like this:

Code:
$bitcoin = new Bitcoin($rpc_user,$rpc_pass,$rpc_host,$rpc_port);

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
The_Trader (OP)
Member
**
Offline Offline

Activity: 180
Merit: 52


View Profile
April 07, 2023, 01:26:12 PM
 #3

I'm not that familiar with PHP so I could be wrong, but it looks like you're passing strings instead of variables here?:

Code:
$bitcoin = new Bitcoin('$rpc_user','$rpc_pass','$rpc_host','$rpc_port');

Instead, it should be like this:

Code:
$bitcoin = new Bitcoin($rpc_user,$rpc_pass,$rpc_host,$rpc_port);

Ha thank you OmegaStarScream

That was exactly what it was, I have been sat here for hours staring at it and trying to figure out what is wrong, I knew it would be simple i was just too pissed off to see it.

Again thanks for the prompt help it was appreciated Smiley

TT
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!