Server side validation

QuestionsServer side validation
Rheal asked 8 years ago

Can someone tell me what is wrong with this bit of code.
It does not return and error like it is suppose too.
My connection is to a MSSQL Server.
Checked the query on the server and it worked fine.

$e["on_insert"] = array("add_client", null, false);

function add_client($data)
{
global $g;

$check_sql = "SELECT count(*) as c from dbo.[User] where [User_ID] = '".$data["params"]["User_ID"]."'";
$rs = $g->get_one($check_sql);

if ($rs["c"] > 0)
phpgrid_error("Client already exist in database");
}

$g->table = "dbo.[User]";

$g->set_events($e);

1 Answers
Abu Ghufran answered 8 years ago

Just a thought, debug the $data array if it contains correct key-value as you are using in query.

You can put:

ob_start();
print_r($data);
$str = ob_get_clean();
phpgrid_error($str);

before the sql, and see the error message on insert.

Your Answer

11 + 6 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?