 |
Power Sellers Unite Bringing Buyers and Sellers Together
|
| :: |
| Author |
Message |
ldgifts
Joined: 06 Feb 2005
Posts: 249
Location: lamps.LDGifts.com
|
| Posted: Sun Jan 01, 2006 3:30 pm Post subject: PHP MySQL Help...please? |
|
|
The server where my domain is located recently updated to the following versions of PHP and MySQL:
PHP Version: 4.4.1
MySql Version: 4.1.14-standard
I have a form located on my site that I can enter the information from a sale, and it will calculate the profit/loss, then I can submit it to a MySQL db. Well...it worked fine until the upgrade of the site. Now I am having a problem with the script, which I believe is here:
$result = mysql_query($sql);
if ($result == 1) {
echo "Record has been Inserted into Your Database";
} else {
echo "Error inserting record";
}
because I am getting the 'Error inserting record' error while trying to submit. It calculates fine, but will not submit to my database.
Can someone help me??? PLEASE! I am begging! I need this stuff for my quarterly tax filing. I appreciate any help!
LDGifts |
|
| Back to top |
|
bidfind_staff
Joined: 24 Dec 2005
Posts: 19
|
| Posted: Sun Jan 01, 2006 3:54 pm Post subject: Re: PHP MySQL Help...please? |
|
|
Hello LDGifts,
Your, error checking, code snippet appears ok... and would be returning a value of "1" if the sql query was successful. You may want to look inside of the "mysql_query" function to see what is happening.
If your hosting service permits access to your DB tables, you can get to the data directly in Mysql to verify whether the data is being updated or not. |
|
| Back to top |
|
ldgifts
Joined: 06 Feb 2005
Posts: 249
Location: lamps.LDGifts.com
|
| Posted: Sun Jan 01, 2006 4:08 pm Post subject: Re: PHP MySQL Help...please? |
|
|
Hello bidfind_staff...and thank you for your response.
I can get into my db's and tables through phpMyAdmin. Nothing is being inserted. Were there changes to php 4.4.1 or MySQL 4.1.14-standard that have changed the way my code is working? I have tried to look at firepages.au and others, but can't seem to find what I am looking for. I know I had to change the way my password and things were entered, but have no clue as to this.
Thanks again for the help!
LDGifts |
|
| Back to top |
|
bidfind_staff
Joined: 24 Dec 2005
Posts: 19
|
| Posted: Sun Jan 01, 2006 4:26 pm Post subject: Re: PHP MySQL Help...please? |
|
|
Hello LDGifts,
Are you able to do other database tasks, such as INSERT or UPDATE other records? If you didnt alter your program, and you didnt alter the table structure... than, most likely, the "permisisons" table may have been overwritten, by your provider, during the updating... just a guess.
Sorry, I dont follow the changelogs for php and mysql... I was only trying to address your immediate question. Have you contacted the software author with this question? |
|
| Back to top |
|
ldgifts
Joined: 06 Feb 2005
Posts: 249
Location: lamps.LDGifts.com
|
| Posted: Sun Jan 01, 2006 4:45 pm Post subject: Re: PHP MySQL Help...please? |
|
|
Myself and a friend created the code...that was why I was asking. I can insert tables and such, but it would not calculate the profit loss by itself.
I just created a php.ini file to take place of the htacess file so that I could turn off safe-mode and turn on register_globals. Now, I can't even calculate. Gonna go back to htaccess file, and try screwing around with the script again.
Thanks again!
LDGifts |
|
| Back to top |
|
ldgifts
Joined: 06 Feb 2005
Posts: 249
Location: lamps.LDGifts.com
|
| Posted: Sun Jan 01, 2006 5:10 pm Post subject: Re: PHP MySQL Help...please? |
|
|
OK...here is the whole sql code:
//CONNECTION STRING
$dbh = mysql_connect ("localhost", "xxxxxxxx_xxxxxxx", "xxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xxxxxxx_orders");
$sql = "INSERT INTO 1QTR05 (
auction_id,
description,
bidder_id,
bidder_name,
start_date,
end_date,
pay_date,
email,
site_name,
pay_type,
pay_id,
ref_date,
shipper,
shipper_id,
track_id,
date_shipped,
bid_amt,
pd_ship,
pd_ins,
state_tax,
ret_fees,
rel_fees,
item_cost,
my_ship,
cust_ship,
insert_fees,
xtras,
fvf_fees,
coupon,
refunds,
pay_fees,
profit_loss) VALUES (
'$auction_id',
'$description',
'$bidder_id',
'$bidder_name',
'$start_date',
'$end_date',
'$pay_date',
'$email',
'$site_name',
'$pay_type',
'$pay_id',
'$ref_date',
'$rel_fees',
'$shipper',
'$track_id',
'$shipper_id',
'$date_shipped',
'$bid_amt',
'$pd_ship',
'$pd_ins',
'$state_tax',
'$ret_fees',
'$item_cost',
'$my_ship',
'$cust_ship',
'$insert_fees',
'$xtras',
'$fvf_fees',
'$coupon',
'$refunds',
'$pay_fees',
'$profit_loss')";
$result = mysql_query($sql);
if ($result == 1) {
echo "Record has been Inserted into Your Database";
} else {
echo "Error inserting record";
}
//***** END INSERT SQL *****//
Thanks for any suggestions or help with this!
LDGifts |
|
| Back to top |
|
bidfind_staff
Joined: 24 Dec 2005
Posts: 19
|
| Posted: Sun Jan 01, 2006 5:37 pm Post subject: Re: PHP MySQL Help...please? |
|
|
Are you runing this code through a webpage? Also, do you have access to the http error file for your site?
If yes to both of the above, then you can run your program, let it fail, and then go look at the error log file... it will give you the sql error. |
|
| Back to top |
|
ldgifts
Joined: 06 Feb 2005
Posts: 249
Location: lamps.LDGifts.com
|
| Posted: Sun Jan 01, 2006 5:47 pm Post subject: Re: PHP MySQL Help...please? |
|
|
Ever since the change, the hosts have told us that the minimum permissions on any php file is 755. I am now thinking this is the problem. I am using a webpage. So, I can't write or execute...DAMN! I had changed it to an html page, but I am still receiving the error.
Here is the error log:
[2006-01-01 15:49:23]: error: file is writable by others: (/home/xxxxxx/public_html/xxxxxx.php)
[2006-01-01 15:49:07]: error: file is writable by others: (/home/xxxxxx/public_html/xxxxxx.php)
[Sun Jan 1 15:49:45 2006] [error] [client xx.xx.xxx.xxx] Premature end of script headers: /home/xxxxxx/public_html/xxxxxx.php
[Sun Jan 1 15:49:23 2006] [error] [client xx.xx.xxx.xxx] Premature end of script headers: /home/xxxxxx/public_html/xxxxxx.php
[Sun Jan 1 15:49:07 2006] [error] [client xx.xx.xxx.xxx] Premature end of script headers: /home/xxxxxx/public_html/xxxxxx.php
What is the premature end of script headers error mean? It worked fine before the upgrade of the servers.
Thanks again for all of your help!
LDGifts |
|
| Back to top |
|
LurkeyLou
Joined: 20 Feb 2005
Posts: 1979
Location: Columbia River Gorge, Washington
|
| Posted: Sun Jan 01, 2006 6:08 pm Post subject: Re: PHP MySQL Help...please? |
|
|
ldgifts, try setting permissions to 644. You'll be able to write, but no one else will.
Changing permissions will likely clear the "...end of script" error.
HtH! |
|
| Back to top |
|
LurkeyLou
Joined: 20 Feb 2005
Posts: 1979
Location: Columbia River Gorge, Washington
|
| Posted: Sun Jan 01, 2006 6:11 pm Post subject: |
|
|
| Oh! What that error is telling you is that the script stopped before it was able to complete it's function, which is likely related to the permissions error. |
|
| Back to top |
|
bidfind_staff
Joined: 24 Dec 2005
Posts: 19
|
| Posted: Sun Jan 01, 2006 6:18 pm Post subject: Re: PHP MySQL Help...please? |
|
|
As for the error message appearing in your error log... it means that the script halted for whatever reason... usually syntax errors in the code. DB errors usually have DB error messages.
When you check your 755 settings, also ensure that the correct uses and groups are set also.
BTW, the "permission" that I am referring to, in a previous message, is not the 755... rather, the "mysql" file where 'rights' are set to your database. That DB gives permission to who can do what on your DB... if that was overwritten during the upgrade, then you may have lost access rights.
However, when this does happen, the usuall error message in the error log is "Access denied for user:<username>" You dont seem to be getting that error message. |
|
| Back to top |
|
ldgifts
Joined: 06 Feb 2005
Posts: 249
Location: lamps.LDGifts.com
|
| Posted: Sun Jan 01, 2006 7:11 pm Post subject: Re: PHP MySQL Help...please? |
|
|
Yes....the permissions were not overwritten, but changed slightly. I did change that earlier.
I have changed the permissions of the file itself to 644...still getting the error. Very strange thing, though...when I looked at the error log after trying to test it again, there were no more error messages that appeared since the last ones I had posted above. Maybe it updates every hour or so? I don't know, but I will check later. Meanwhile, I have to go look at some websites to try and figure out what the problem is with the code. Like I said, it has worked fine for a year or so since we wrote it.
Thanks for the help, both of you...I really do appreciate it.
LDGifts |
|
| Back to top |
|
LurkeyLou
Joined: 20 Feb 2005
Posts: 1979
Location: Columbia River Gorge, Washington
|
| Posted: Sun Jan 01, 2006 7:46 pm Post subject: |
|
|
Y/W, ldgifts...hmmm. I'm wondering if changing the permissions for your directory to 644 will clear the problem? Your error log should be in real time, if it's updating hourly, I'd address this with your host.
Sorry I can't help better...but I hope you find the solution very quickly!! |
|
| Back to top |
|
ldgifts
Joined: 06 Feb 2005
Posts: 249
Location: lamps.LDGifts.com
|
| Posted: Sun Jan 01, 2006 9:41 pm Post subject: Re: PHP MySQL Help...please? |
|
|
It is the main directory, which was given 750 permissions. I am just going crazy....I think I will just open up the apache server on my own pc, and just enter it onto here. Like I said before, it worked perfectly prior to the upgrade. It should work on my own box. I have to figure it out sooner or later, but looks like later. I need to do my taxes!
Have a wonderful New Year!
LDGifts |
|
| Back to top |
|
psunite
Joined: 27 Jan 2005
Posts: 6213
Location: Columbus OH
|
| Posted: Sun Jan 01, 2006 10:08 pm Post subject: |
|
|
ldgifts
add an
echo $sql;
to your code and see if its outputing a valid sql.
If you have phpmyadmin you can then cut and paste that sql statement and see if its valid. |
|
| Back to top |
|
| |
|  |