# Page stalling when using MySQL with PHP under WebStar



## lasar (Oct 23, 2003)

Greetings everybody.

We have a rather obscure problem with our OSX webserver here.

We're running WebStarV with PHP as a CGI (version 4.3.3) and MySQL (version unclear).

When someone loads a PHP page that connects to the MySQL database and then proceeds to write something to the database, the page never loads (the data to be saved also isn't saved).

Fun thing is that I seem to be able to connect to the database and read from it just fine.

Has anybody seen this problem under any system? I'm not even sure what the culprit is, but somewhere something locks up. Once PHP/MySQL has died every PHP page will never send its data, only a restart of WebStar will fix the problem.

THanks,

_Lasar


----------



## Pengu (Oct 23, 2003)

Sounds like the page in question is making PHP and/or WebStar go into an endless loop or something simmilar. Check the php page for errors.
Can i ask why you're using WebStar?


----------



## lasar (Oct 23, 2003)

The PHP page has no loops, that side should be OK. I don't believe it's a syntax/programming problem.

I'm using WebStar because I have to. I'd rather run Apache on Linux or even OSX too, but I have no choice:/

Thanks,

_Lasar


----------



## Arden (Oct 23, 2003)

See if there's something fishy in your PHP settings.  To check this, create a new file and enter *phpinfo()* as the only thing in that file, then save it somewhere however you like (I would save it as "phpinfo.php").  Then open it in your browser.


----------



## lasar (Oct 23, 2003)

Sadly, nothing to see there.
Feel free to look at it, but it looks like a perfectly normal PHP setup to me
http://test.base-t.de/info.php
I am currently setting up a test server to see what exactly is causing it.


----------



## Pengu (Oct 23, 2003)

Can you post the code from the offending php file, or is it against company rules??


----------



## lasar (Oct 23, 2003)

<?php

if ( $_GET["submit"] != "Abbrechen" ) {
	$id = $_GET["id"];
	$text = $_GET["text"];
	$title = $_GET["title"];

	if ( $id ) {
		// Aenderungen speichern
		$query = "update $mysql_table set date=".time().", title='".addslashes($title)."', text='".addslashes($text)."', sort='".addslashes($sort)."' where id=$id and kategorie=$category";
	} else {
		// Neuer Eintrag.
		$query = "update $mysql_table set sort=sort+1 where kategorie=$category";
		mysql_query ( $query );
		$sort = 1;
		$query = "insert into $mysql_table (date,kategorie,title,text,sort) values (".time().",$category,'".addslashes($title)."','".addslashes($text)."','".addslashes($sort)."')";
	}

	mysql_query ( $query );
}

include ( $templates."admin_back.php" );
?>


----------



## lasar (Oct 23, 2003)

That's the code that always kills PHP or whatever. I can't find anything wrong with it :/
There's a function that does a perfectly normal mysql_connect() and mysql_select_db(), but does nothing much else.
I'm sure that it's no malicious code inserted via a loophole either, because the page isn't accessible by anyone but me.


----------



## Pengu (Oct 23, 2003)

Whenever I run into problems like this, I comment out everything, and go through line by line, adding it back in, with a very simple echo statement put in somewhere to make sure the page is loading properly. If it turns out to be your SQL, try echoing the $query, and then see what happens if you run that query through mysql using either the cli client, or phpmyadmin or simmilar...


----------



## lasar (Oct 27, 2003)

I've found the problem and fixed my script to work. The problem as it remains, though:

When I send a large amount of data (about 4000 characters do it here) via a form using the GET protocol, PHP or whatever stalls. Using POST works fine. I've switched my script to POST so it's solved here, but from the looks of it anybody can crash PHP on any WebStar server by sending it lots of data.
To test I used a PHP page that, next to basic HTML, contained only a print command, so it is not, as I previously assumed, the database.
Can anybody confirm this problem or tell me if it is maybe a known problem? 4d has been notified.


----------



## Pengu (Oct 27, 2003)

Maybe something to do with the server settings, either PHP or Webstar, regarding maximum size of GET variables??


----------



## lasar (Oct 27, 2003)

I shall have to look. But it can't be that the default settings (I have changed practically nothing and certainly nothing regarding these matters) allow PHP to be crashed.


----------



## Pengu (Oct 27, 2003)

It could also be affected by the browser. it may be truncating the variables in the address bar, due to length. If its that amount of text, can't you simply tell it to use the POST method?


----------



## lasar (Nov 3, 2003)

The problem is reproducible with Safari and Internet Explorer. Of course I can tell it to use the POST method, and I did. Which fixed the problem for now.

But the _real_ problem remains: Anybody who knows of this problem and knows I am running WebStar can in theory build a little form pointing at a PHP page on my server, enter lots of data and submit via GET, and PHP on my server dies.

The 4D people have been notified, we'll see if it helps.


----------



## Captain Code (Nov 3, 2003)

The problem is indeed with the GET.  It can have a max of I think 256 characters, where POST does not have a limit!


----------

