Log in

View Full Version : Problem to store data in mysql through PHP with javascript and ajax



JoeBlack
11-02-2012, 11:37 AM
Hi!
First of all i beg your pardon for my bad english. It isn't my native language. Second, i don't know really what the problem is. I assume it's a PHP problem but it could be something else. So this could be in the wrong forum.
Ok, i try to explain my problem now *sigh*

The user comes through my login pages to startseite.php. There is a menue where he can choose Kunden -> neu. This opens a new site k_neu.php into an other div (ajax container) some lower to the menu which still remains visible. There he can input some data, k_neu.js checks the data and then the php should send the data to the mysql db but nothing happens. I tried the sql-statement in the mysql console and it works. So, its not a sql problem. I'm a beginner in web-coding so i don't know what to do. Firebug tells me only warnings (which are unfortunally pretty normal in web-coding as i learned so far...) and no real errors. The apache2 log file tells me something about php which i can't understand.

I post my code on pastebin because .php is not a valid extension.
startseite.php : http://pastebin.com/mGv4wHsB
The css to see the page properly:
style.css : http://pastebin.com/dB98FBhq
k_neu.php : http://pastebin.com/9XDMPWx1
k_neu.js : http://pastebin.com/6kGAV6G5
From apache2:
Default apache2 error log : http://pastebin.com/WVqK9nBn
apache2 error log of the vhost which i use : http://pastebin.com/4yhLCREe
And there is the ajax code which i use:
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

I hope this is enough to make my problem clear and that here is someone with a purpose to fix it.

Regards,
Joe

EDIT: Ignore the screenshot. I didn't know that ksnapshot makes such useless small screenshots despite fullscreen was selected and i don't know to remove the file in the upload manager.
anyway, firebug has this 2 warnings:

TypeError: function ajaxpage does not always return a value
function ajaxpage(url, containerid){
startseite.php (line 46)

and

ReferenceError: assignment to undeclared variable i
for (i=0; i<arguments.length; i++){
startseite.php (line 80)

This is how it looks like while browsing through the menu:
http://img821.imageshack.us/img821/3867/bildschirmfoto3h.png
http://img696.imageshack.us/img696/4889/bildschirmfoto4s.png
And this after i hit 'speichern' to send the data to the mysql db.
http://img826.imageshack.us/img826/9962/afterc.png
No, error at all. Just a ajax warning and no data at the tblKunde table.

traq
11-02-2012, 02:09 PM
Your error log doesn't match up with the PHP scripts you posted - line numbers, etc. don't match. Are you sure that's the complete, correct script? I'll look at everything a bit more later today.

JoeBlack
11-02-2012, 02:24 PM
Sorry, i should have cleared the log file before i posted. I just copied the last entries. I stopped the apache, cleared the log file, restarted it, and reproduced the process on the web page. After that the vhost error log was (surprisingly) empty and only the (default) apache2/error_log had this 2 lines: http://pastebin.com/eeLs2R0v

traq
11-02-2012, 05:23 PM
You should remove your DB credentials from your pastebin posts.
You should never post passwords, usernames, or other sensitive information online.
You should obfuscate them in your posts (for example, replacing "password" with "********").

Is k_neu.js a plain javscript file, or is it generated by PHP?

What I'm getting at is this:
document.form1.action = <?php $_SERVER['PHP_SELF']?>;
Is that what it actually says in your script, or does it show the correct URL?


*****
Talk to your web host about the Init warning (I doubt it's related to this problem, but it should be dealt with).

JoeBlack
11-03-2012, 04:22 AM
I know about the sensitive password publishment but the page is far form being online and i will change all passwords/hashes/rights/etc. when my project is final. Anyway i will do what you said and make the passwords irrecognizable.
k_neu.js a plain javascript file. Solid and not generated. The code is equal to the code in the file. Line 31,32,33 was a try to fix the problem but it didn't work. The result is the same with or without these 3 lines. What do you mean with 'Init warning'? The server of the website is a virtual machine (suse linux 12.2) running apache2 and i have full control over it (root).

JoeBlack
11-05-2012, 08:43 AM
Shall i start a 'DD scripts Paid Help' thread or a 'General Paid Work Requests'? How much is the usual price?

keyboard
11-05-2012, 08:50 AM
If you're looking for paid help, post in the General Paid Work Requests forum.
The DD scripts Paid Help forum is for paid help concerning the scripts found on Dynamic Drive.

The price is completely up to the developer.
Post there and people should be able to give you a quote (if they want to take the job).

djr33
11-05-2012, 04:16 PM
Note: you can also post a price of your choosing (and say whether is it or is not negotiable). It's your choice. I'd say usually the developers set the price, but that's not a rule.