Post by sexysarah1980 » Mon Aug 06, 2012 12:13 am

Hellow everyone,

I have an OC install in my root domain and a wordpress install in /blog.

I am trying to see if the user is logged into OC so I created a file with some of the OC code used in other files, (test.php) uploaded it to my /blog folder and called it in my browser. http://www.domain.co.uk/blog/test.php.

This returns the corect result and shows the user is logged into my OC shop. Great...Except for when I copy this code into the wordpress header.php (twentyeleven theme) When I then go to /blog I get the following errors:

Code: Select all

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'myprefix_myuser'@'localhost' (using password: YES) in /home/myprefix/public_html/system/database/mysql.php on line 6

Notice: Error: Could not make a database link using myprefix_myuser@localhost in /home/myprefix/public_html/system/database/mysql.php on line 7

Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/myprefix/public_html/system/database/mysql.php on line 10

Notice: Error: Could not connect to database myprefix_myuser in /home/myprefix/public_html/system/database/mysql.php on line 11

Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/myprefix/public_html/system/database/mysql.php on line 14

Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/myprefix/public_html/system/database/mysql.php on line 15

Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/myprefix/public_html/system/database/mysql.php on line 16

Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/myprefix/public_html/system/database/mysql.php on line 17
I assume the 1st is causing the rest but why would this happen? I have seen a few examples of others doing this an nobody seems to have had this issue so im stuck. Unfortunately I dont know wordpress that well so im not sure where to start looking. I assume something is happening before the header.php is called in wordpress and thats causing the issue.

Has anybod got any ideas or a working way to check the customer is logged in froma new wordpress install?

Thank you.
Sarah

I ahve attached the 2 files I am using. The code from test.php is exactly the same as added to the top of hearder.php.

Newbie

Posts

Joined
Sun Aug 05, 2012 11:58 pm

Post by prodigitalweb » Mon Aug 06, 2012 4:20 am

Hi sexysarah1980,


Can you know if the user is logged in your OpenCart referring to the $ _SESSION.

If you do a print_r ($ _SESSION), you'll see what OpenCart saves in session when a user is logged.

Hope this helps.
If you have any other inquiries, please contact me.


Greetings!

New member

Posts

Joined
Mon Aug 06, 2012 3:08 am

Post by sexysarah1980 » Mon Aug 06, 2012 5:52 am

Hi, Thanks for your reply.

Yes I can access session data so I cant understand whats happening. Other people seem to have had this working using pretty much the same code but I guess it may be down to different OC/Wordpress versions. To clarify, I am using 3.5.1 on OC and Wordpress 3.4.1

If I use the code given I get:
Array ( [currency] => GBP [user_id] => 1 [token] => 1992cc57e2b2be9fc666659bd9d048c4 [language] => en [cart] => Array ( [735] => 1 [363] => 3 ) [captcha] => 09bb40 [vouchers] => Array ( ) )

So what cold be causing this? I tried removing the entire contents of the wordpress header.php and adding just the test.php page and it still fails (despite both files being in a sub folder)

Any ideas?
Thanks
Sarah

Newbie

Posts

Joined
Sun Aug 05, 2012 11:58 pm

Post by sexysarah1980 » Tue Aug 07, 2012 3:59 am

Does anybody have any ideas on how to accomplish this? I wouldn't have thought this was difficult to do considering the session data seem to be readable from inside my /blog folder. (It just fails when I try to access it from wordpress header.php)

So, just to clarify, has anybody managed to check if the reader is logged in from inside the wordpress header.php?

Oh, typo above. My OC is 1.5.3.1 just to clarify. Any help would be great as im just about to give up! :(

Newbie

Posts

Joined
Sun Aug 05, 2012 11:58 pm

Post by sexysarah1980 » Wed Aug 08, 2012 5:15 am

Don't worry, I figured it out and its now working as expected.

Newbie

Posts

Joined
Sun Aug 05, 2012 11:58 pm

Post by karunshakya » Tue Aug 28, 2012 11:32 am

I am having the similar problem can you help me? I want to show user logged-in in opencart in wordpress. When I log-in in opencart its fine but when i switch to wordpress I again get the same "You are not logged-in please login" message.

User avatar
Newbie

Posts

Joined
Tue Jul 24, 2012 7:03 am
Location - Nepal
Who is online

Users browsing this forum: No registered users and 4 guests