Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am trying to add new user to members table, but it doesn't work without errors.

The insert query works well in my local server, but it doesn't work on remote server without error.

Remote server:

Hosting: InMotionHosting.com
Platform: Linux / Apache 2.4.39/PHP 7.0.33 /mySQL 5.7.26

Local Server:
Platform:Windows 10 / Apache/2.4.39 (Win64) / PHP 7.1.28 /mysqlnd 5.0.12-dev - 20150407

What I have tried:

Here is my code snippet.

function adduser($itemData)
{
	$qfields = "(";
	$qvalues = " VALUES ('";
	$countFields = 0;
	foreach($itemData as $key=>$value)
	{
		$countFields++;
		$qfields .= '`'.$key;
		if ($countFields == sizeof($itemData))
		{
			$qfields .= "`) ";
		}
		else
		{
			$qfields .= "`, ";
		}

		$qvalues .= $value;
		if ($countFields == sizeof($itemData))
		{
			$qvalues .= '\')';
		}
		else
		{
			$qvalues .= '\', \'';
		}
	}
	
    $query = 'INSERT INTO `members`'.$qfields.$qvalues.';';

    $result = mysqli_query($GLOBALS['link'],$query);

    if (!$result) {
        mysqli_error($GLOBALS['link']);
	    die($query);
    }

    updatepass($itemData['password'],mysqli_insert_id($GLOBALS['link']));
    return mysqli_insert_id($GLOBALS['link']);
}


If this code run on remote server, it stop after displaying the query.
If you know why , tell me the reason and solution.
Thanks
Posted
Updated 10-Jul-19 4:11am
v2
Comments
Herman<T>.Instance 8-Jul-19 6:59am    
Is there any exception cq fault message? What have you debugged?

1 solution

I would try the following experiment:

Hard code in all the values that depend upon, for example, global values. Anything else you can.

If it works locally, then try this on the server.
If it works then you know your problem's with your access of the various Global values. If it fails, continue simplifying external dependencies.

Also - don't forget, if necessary, to break it down into testable steps.
Does your query return data when run on the server? If there's an error message, you need to post it (either a reply to a comment/answer, or modify your original question).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900