Jump to content

Odd problem, ajax related


Lashiec

Recommended Posts

I'm building a site, and it's using a lot of AJAX calls to php scripts. To make things easier for me I made one php file and put all my ajax scripts in there. So, when I call that page I send a $_GET variable to it and then in the php file I have a switch to go to a certain section of code that I want it to. It works fine and everything, but I have a really weird problem.

 

With a few blocks of code it'll give me weird errors, like certain variables aren't there (notices) and some of my mysql syntax is wrong (mysql_error) and so on, but the weird thing is that the script actually completed just fine and did what it was suppose to. This can cause some problems because I'm usually echoing some variable that the ajax call will pick back up and do something based on what variable was returned...

 

Now for the odd thing, I had this block of code, pretty much adding stuff to a database and creating a new column in a database. At the end of the code I did an echo of a variable, and it wouldn't work because it was saying I had a mysql error... But, when I put the echo before any of the code it doesn't give me the mysql error anymore. It works for this certain block of code because the returned variable is never changed, but for some it has to be at the end. I also noticed if I echo'd out all of my mysql strings it wouldn't give me an error, and they all looked correct.

 

I'm using a database class I build myself and it doesn't seem to give me any problems when I use it, and I don't think that it is the problem because it's been used in multiple places already. Here is the code... Not that it'll make much sense since it's mostly using my database class, and I don't really want to post it (it just builds a string that gets passed to the database).

 

If anyone has any ideas what could be going on with this that'd be great... I see no errors in any of my code, and even if it does send an error it seems to work anyways!

 

case 'addtosection': { //adds a new column to section, addtosection.php
			echo $_GET['section'];
			$db->select_table($db_sections);
			$db->doit(array('select' => 'sec_order', 'where' => array(array('AND', "section::$_GET[section]")), 'limit' => 1));
			$row = $db->output();
			$db_order = $db->doit(array('select' => array('max' => 'db_order'), 'where' => array(array('AND', "section::$_GET[section]"))), 'math');
			if(isset($_POST['showing'])) $show = 'Y'; else $show = 'N';
			$id = $db->doit(array('insert' => array('sec_order' => $row['sec_order'], 'db_order' => ($db_order['math']+1), 'label' => $_POST['label'], 'type' => $_POST['type'], 'section' => $_GET['section'], 'showing' => $show)), 'insert id');
			$name = ($id['insert_id'].'_'.strtolower($_POST['name']));
			$db->doit(array('update' => array('name' => $name), 'where' => array(array('AND', "id::$id[insert_id]"))));
			$db->select_table($db_prefix.$_GET['section']);
			$db->doit(array('add column' => array($name => convert_sql($_POST['type']))));
		} break;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.