We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Very simple PHP script and mySQL problem. Please help!

wins0ck21 asked
Medium Priority
Last Modified: 2013-12-12
Hello there, I am absolutely desperate to get this to work.
My current setup is a nuonce-bluequartz-centos server, running php 4.3.9, and mysql 4.1.20
I have downloaded, setup, and configured the php script "myInvoice" from http://www.widgetmonkey.com/detail.php?id=18 
and followed the instructions step by step. I do not have phpmyadmin installed so I had to enter the data from the clients.sql and invoice.sql files manually on my server into my mysql DB I created called myinvoice

After completing step 3 on that website, I am stuck.

I try to login with the default username and password of admin:admin at my site and nothing happens! No error message, nothing. It just reloads the login page again. This is supposed to be a simple php script.....I don't care if I have to give ssh access to my box for someone to take a peek at this, I need this thing to work. Any help would be VERY much appreciated!!! Thank you!!
Watch Question

How did you enter clients.sql and invoice.sql?
Can you access mysql using command line? such as "mysql -h localhost -u admin -p "?
Have you set user+password to access your mysql server (not your application)?


I entered clients.sql and invoice.sql manually, opening it in notepad on one computer, while going back and forth to the server and typing it in there (after logging in to mysql via "mysql -p")
I also confirmed its entry by doing  "SHOW databases;", "use myinvoice;", "SHOW tables;"
I have full access to mysql using the command line (local server access)
I have also added a username "invoice" and its password access to the mysql database "myinvoice", but even when I use root as the user, it doesn't seem to make any difference.
This thing is really frustrating me

Can you list all of your mysql users? Because some times I found problem connection my sql because there are two user root there.

And how did you connect to mysql via php? mysql_connect(xxxx,xxx) ..


I'm new to mysql, I don't know the command to list all of the users.

it connects to mysql via php using the dbconnect.php file in the folder "inc", which reads:


$db = mysql_connect("$hostname", "$user", "$pass");

the config.php file is configured with the login credentials and everything needed to connect which is basically the first four lines of the file:

$database = "myinvoice";
$user = "root";
$pass = "****";
$hostname = "localhost";

ok, if you can access mysql using "mysql -p", try this command:

> use mysql; <ENTER>
> select host, user, password from user;<ENTER>

let me know the result.


I just changed the user in config.php to use the user "invoice", which has access to the myinvoice database so that file now reads:
$database = "myinvoice";
$user = "invoice";
$pass = "****";
$hostname = "localhost";

I will change back to root if you suggest that as i don't know what's better.

I dont know how I could copy and paste it from my server to workstation so I'll type out the approximate result

result is:

host                                     user                 password
localhost                               root                 7cf83f47641ae562
localhost.localdomain             root                
localhost                               invoice             1ad0d8c8271eaad6

5 rows in set (0.00 sec)

I often found those similar problem, where there are 2 users "root". Usually, I remove one of then, then connect my data using root users.

Try delete root user, and leave just one user "root" (and also "invoice"), using this command:

>use mysql;<ENTER>
>delete from user where host = "localhost.localdomain";<ENTER>
>delete from user where user is null OR user = '';<ENTER>
>flush privileges<ENTER>

I don't know why mysql create 4 users for default, usually I only use 1 user root.

Then try using root to connect your mysql database.
NB: i think you can use "invoice" user too, but failed because the privileges of this user are insufficients.

Hope this helps ;)


I entered the commands, and confirmed it with

use mysql;
select host, user, password from user;

it now shows only 1 root user and the invoice user.

I also changed the config.php file back to connect with the root user.

Unfortunately for me, after entering username "admin" and password "admin" it still did nothing but refresh the login page :/
there must be something else causing this not to work i just don't know what.


I went back to the website of the php script and was reading that creating a seperate database was optional, which i did by creating "myinvoice" , maybe I should just enter the data from clients.sql and invoice.sql into the default mysql database, configure config.php to connect there, and see if that makes any difference.
Instead of having to type the data from the .sql files in manually, is there an easier way of doing this? a command to just copy the data from the file into a table?

NO, don't use mysql database. I think you should create different database.

Could you check if your connection OK? I just want to figured out, wheater the problem is on your connection to mysql, or on your application.

I your can connect to mysql successfully, but fail to login using user admin/admin, then perhaps you don't have user admin/admin in myinvoice database.


admin:admin was added when the data from the clients.sql file was entered into the table during initial install and configuration
but just to confirm...

I checked by typing:

mysql -p
use myinvoice;
show tables;
describe clients;
select * from clients limit 1;

and it shows:
clientid    name       password                       email                                      ref        title
1             admin     43e9a4ab75570f5b         myemail@mydomain.com                     admin

so it must be in then?

Thank you for helping me, please don't give up. Its probably some stupid thing causing this not to work.

Well, i think user admin is in database :-?

Did you get error message while execute the php script?
Perhaps you need to turn on you display_error ini php.ini


I have located the file php.ini in both /etc  and also in /etc/admserv

When setting display_errors = On  in both files and then trying to executing the script, it still doesn't display any errors. Seems pretty odd to me.

in the file:

; - display_errors = On

but because I dont really understand the file because it has the ";" semicolon on almost every line I'm thinking that's something like a comment?  so I also added
display_errors = On  its own line without the "; -"
either way, it still does not display any errors after i try logging in :/

Yes, semicolon is for comment.

Try to modified your php.ini, in these lines:

error_reporting  =  E_ALL
display_errors = On

To make sure that php displays error, try to make any error in your php scripts.
Sorry, we need to make sure where the problems is :).


AHA! I'm finally getting somewhere with this...
I went through the entire php.ini file looking for any errors to set to on, including mysql errors just incase and after logging in I got this:

Notice: Undefined variable: name in /home/.sites/70/site4/web/myinvoice/login.php on line 4

Notice: Undefined variable: password in /home/.sites/70/site4/web/myinvoice/login.php on line 4

Notice: mysql_db_query(): This function is deprecated; use mysql_query() instead. in /home/.sites/70/site4/web/myinvoice/login.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /home/.sites/70/site4/web/myinvoice/login.php:4) in /home/.sites/70/site4/web/myinvoice/login.php on line 33
Well, 1rst and 2nd notices are because you use globar environment, but it seems that it is turn off in your php.ini

Check this configuration:
register_globals = On

For 3rd notice, i thik it's better if you change mysql_db_query into mysql_query.
4th notice happened because of the notices.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Kurnia, Thank you very much for all of your help, unfortunately I have come to the conclusion that this php script is too outdated for the modern software. It was created in 2003 around the time RedHat 9 was out and has never been updated since. I very much appreciate the time you have taken to help me with this but I will just have to find some other way of getting my invoices set up on my site. If you want to continue with this, I will do whatever you tell me to, but unless its updating or re-writing the php script I don't think it's going to work, or unless I install it on a redhat 9 box and turn that into my webserver. Anyway, Thank you.


Although this remains incomplete. I would like you to get the points for your time, I really appreciated it.



Warning: Wrong parameter count for mysql_query() in /home/.sites/70/site4/web/myinvoice/login.php on line 5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/.sites/70/site4/web/myinvoice/login.php on line 6

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/.sites/70/site4/web/myinvoice/login.php on line 30

Warning: Cannot modify header information - headers already sent by (output started at /home/.sites/70/site4/web/myinvoice/login.php:5) in /home/.sites/70/site4/web/myinvoice/login.php on line 33

Thanks for your point.

If you don't mind, will you gave my your software? Maybe you can place it in your site where I can download it, perhaps I can analyze more.

About your last comment, the first 3 warning are error on syntax : not enough parameter, or wrong parameter. Last warning happen because the error above.


Sure, I placed it in my site so you can download it, it's also the site I was trying to get it to work on.
You can download it from:


I try logging in at http://www.computerrepairsvc.info/myinvoice/        with admin:admin
Let me know if you figure something out or change/update the script enough to make it functional again. Thanks.


I have install the application, and it run ok, although not to smooth. It's work well, with some notices that can be iqnored.

Sorry, perhaps my last suggestion is incorrect.
I think you still need to use mysql_db_query, instead of mysql_query, cause I use that and run OK.


I don't understand why it works with you but not me, unless your linux is older. I'm trying to run it on CentOS 4.3.
So I changed it back to mysql_db_query and it now says:

Notice: mysql_db_query(): This function is deprecated; use mysql_query() instead. in /home/.sites/70/site4/web/myinvoice/login.php on line 5

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/.sites/70/site4/web/myinvoice/login.php:5) in /home/.sites/70/site4/web/myinvoice/login.php on line 8

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/.sites/70/site4/web/myinvoice/login.php:5) in /home/.sites/70/site4/web/myinvoice/login.php on line 8

Warning: Cannot modify header information - headers already sent by (output started at /home/.sites/70/site4/web/myinvoice/login.php:5) in /home/.sites/70/site4/web/myinvoice/login.php on line 22

Hmmm :-? I'm using newest Ubuntu version, but my php is PHP4, and I'm using MySQL 4.
Well, I've found why mysql_query didn't work.
You need to add this line after mysql_connect:

I'ts work fine here.
Then, you will find another error like this :
  mysql_result(): Unable to jump to row 0 on MySQL result index

It's because mysql_result return no record.
If you check the code, you'll find this script: $clienttitle = mysql_result($clientfind,0);
In those case, to eliminate the error, change the script into :

if ($row1 = mysql_fetch_array($clientfind))
    $clienttitle = $row1['title'];
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.