Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed May 15, 2013 10:01 pm 
Offline
Newbie

Joined: Wed May 15, 2013 9:57 pm
Posts: 3
Hey,

I just started using linode and so far I have followed the guides to set up a webserver and stuff like that. Also got a domain: sqdejan.com. I have installed Apache, mysql and php. When I upload php files with simple php code it will show. But once I put in some mysql code it can't even load the page: sqdejan.com/mysqlconnect. At least it should say failed to connect. I have tried it on another server where the script works fine. What am I doing wrong? Why can't it read mysql code?

Thanks


Top
   
PostPosted: Thu May 16, 2013 12:07 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
It could be many things:
1. You may not have created the database you're trying to access.
2. You may not have created a MySQL user and password.
3. You may not have given the MySQL user the appropriate rights to access the database.
4. Your web app may not be configured to use the right server.
5. Your web app may not be configured to use the right database.
6. Your web app may not be configured to use the right username and password.

You can test 1-3 by logging in to your Linode and running the following command, substituting the appropriate values:
Code:
mysql -u [username] -p [database_name]

You should then be able to issue SQL commands like SHOW TABLES; or SELECT * FROM [table_name] LIMIT 5;.

Items 4-6 depend on what parameters you're using in your PHP code.

There could also be errors in the code; perhaps it was written for a different version of PHP than what is running on your Linode. Check your PHP error logs.


Top
   
PostPosted: Thu May 16, 2013 7:36 am 
Offline
Senior Member

Joined: Mon Jan 02, 2012 12:45 pm
Posts: 365
sqdejan,
- Do you have 'display errors' enabled in PHP?
- Are you displaying the mysql error? (see http://php.net/manual/en/function.mysql-error.php)
- Are you displaying the mysql results you're selecting?

MSJ


Top
   
PostPosted: Thu May 16, 2013 9:27 am 
Offline
Newbie

Joined: Wed May 15, 2013 9:57 pm
Posts: 3
@MSJ

Ye, I have set it up to display errors according to the guide:

max_execution_time = 30
memory_limit = 128M
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = On
log_errors = On
error_log = /var/log/php.log
register_globals = Off

and this is the very simple code I am running:

<?php
mysql_connect("localhost", "lol", "lol");
?>

On another server I get the message in the browser:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'lol'@'localhost' (using password: YES) in /var/www/web10/html/timtherobot/mysqlconnect.php on line 2

But the problem is I dont get that on my own webpage. It is like its not even trying to connect.

@Vance

Ye I got database and users etc.. But the problem is my, atleast I think, is that it does not execute the code, all I want it to say is the same error as mentioned above. Just to indicate that it at least trying to connect to mysql. But my browser just says "Server fail" (roughly translated)

I can retrieve from the error_log

PHP Fatal error: Call to undefined function mysql_connect() in /root/public/sqdejan.com/public/mysqlconnect.php on line 2

But I have installed php5_mysql on my server.

I am so lost :(


Top
   
PostPosted: Thu May 16, 2013 10:54 am 
Offline
Senior Member

Joined: Sun Aug 31, 2008 4:29 pm
Posts: 177
Restart Apache (or php5-fpm if you're using that).

_________________
sleddog


Top
   
PostPosted: Thu May 16, 2013 12:17 pm 
Offline
Newbie

Joined: Wed May 15, 2013 9:57 pm
Posts: 3
Already done that - doing that everytime I make a change. Also tried to restart mysql! I have just followed the guide on how linode is suggesting that you set up a webserver! This is so wierd.


Top
   
PostPosted: Sat May 18, 2013 3:58 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
sqdejan wrote:
I can retrieve from the error_log

PHP Fatal error: Call to undefined function mysql_connect() in /root/public/sqdejan.com/public/mysqlconnect.php on line 2

But I have installed php5_mysql on my server.


That is strange. While mysql_connect() is deprecated, it should still be available for use.

It's possible you have conflicting packages from different repositories. Can you list the packages you have installed? Try yum info installed '*mysql*' '*php*' on Fedora/CentOS or aptitude -F '%c %?p# %?v# %?t#' search '~n(mysql|php)' | grep '^i' on Debian/Ubuntu.


Top
   
PostPosted: Sat May 18, 2013 11:50 am 
Offline
Senior Member
User avatar

Joined: Tue Nov 24, 2009 1:59 pm
Posts: 362
Not to be totally silly, but do you have the mysql module uncommented in php.ini?
Best thing, share phpinfo() and the php.ini you've seen listed as used in the phpinfo output.

_________________
rsk, providing useless advice on the Internet since 2005.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group