Solved

Very simple PHP script and mySQL problem. Please help!

Posted on 2006-11-02
24
269 Views
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!!
0
Comment
Question by:wins0ck21
  • 13
  • 11
24 Comments
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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)?
0
 

Author Comment

by:wins0ck21
Comment Utility
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
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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) ..
0
 

Author Comment

by:wins0ck21
Comment Utility
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:

<?
include("inc/config.php");

$db = mysql_connect("$hostname", "$user", "$pass");
mysql_select_db("$database","$db");
?>

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";

0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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.
0
 

Author Comment

by:wins0ck21
Comment Utility
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.localdomain
localhost
localhost                               invoice             1ad0d8c8271eaad6

5 rows in set (0.00 sec)
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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 ;)
0
 

Author Comment

by:wins0ck21
Comment Utility
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.
0
 

Author Comment

by:wins0ck21
Comment Utility
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?
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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.
0
 

Author Comment

by:wins0ck21
Comment Utility
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.
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:wins0ck21
Comment Utility
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 :/
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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 :).

0
 

Author Comment

by:wins0ck21
Comment Utility
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
0
 
LVL 1

Accepted Solution

by:
kurnia earned 150 total points
Comment Utility
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.
0
 

Author Comment

by:wins0ck21
Comment Utility
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.
0
 

Author Comment

by:wins0ck21
Comment Utility
Although this remains incomplete. I would like you to get the points for your time, I really appreciated it.
0
 

Author Comment

by:wins0ck21
Comment Utility

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
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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.
0
 

Author Comment

by:wins0ck21
Comment Utility
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:

http://www.computerrepairsvc.info/myinvoice_v1.zip

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.
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
Hi,

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.
0
 

Author Comment

by:wins0ck21
Comment Utility
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
0
 
LVL 1

Expert Comment

by:kurnia
Comment Utility
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:
  mysql_select_db($database,$connection);

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'];
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now