Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Very simple PHP script and mySQL problem. Please help!

Posted on 2006-11-02
24
Medium Priority
?
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 11
24 Comments
 
LVL 1

Expert Comment

by:kurnia
ID: 17879102
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
ID: 17884504
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
ID: 17888281
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:wins0ck21
ID: 17888520
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
ID: 17888587
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
ID: 17888676
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
ID: 17888777
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
ID: 17888878
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
ID: 17888987
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
ID: 17889237
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
ID: 17889581
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
ID: 17889665
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
 

Author Comment

by:wins0ck21
ID: 17889911
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
ID: 17894862
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
ID: 17897239
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 300 total points
ID: 17898590
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
ID: 17905820
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
ID: 17905839
Although this remains incomplete. I would like you to get the points for your time, I really appreciated it.
0
 

Author Comment

by:wins0ck21
ID: 17905849

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
ID: 17906444
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
ID: 17907222
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
ID: 17908133
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
ID: 17908528
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
ID: 17914110
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

688 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