Jump to content

Hi Guys..

 

I am a new in PHP programming... I want to make a page that will connect and getting data in SQL SERVER.

but i want to use a stored procedure.  I have a stored procedure in my database any help how can i call or use SP_ValidateUser in PHP?

any link in tutorial plsssss.

 

 

Thank You..

Link to comment
https://linustechtips.com/topic/755422-php-programming-help/
Share on other sites

Link to post
Share on other sites

36 minutes ago, Leomarc said:

Hi Guys..

 

I am a new in PHP programming... I want to make a page that will connect and getting data in SQL SERVER.

but i want to use a stored procedure.  I have a stored procedure in my database any help how can i call or use SP_ValidateUser in PHP?

any link in tutorial plsssss.

 

 

Thank You..

So you have PHP code in the database that you want to execute?

Look up the "eval" command in PHP.

Second of all, please dont do this, its very dangerous.

Database compromises (which are really common with SQL injection hacks) will basically give the attacker full control over the web server.

Desktop: Intel i9-10850K (R9 3900X died 😢 )| MSI Z490 Tomahawk | RTX 2080 (borrowed from work) - MSI GTX 1080 | 64GB 3600MHz CL16 memory | Corsair H100i (NF-F12 fans) | Samsung 970 EVO 512GB | Intel 665p 2TB | Samsung 830 256GB| 3TB HDD | Corsair 450D | Corsair RM550x | MG279Q

Laptop: Surface Pro 7 (i5, 16GB RAM, 256GB SSD)

Console: PlayStation 4 Pro

Link to comment
https://linustechtips.com/topic/755422-php-programming-help/#findComment-9553105
Share on other sites

Link to post
Share on other sites

2 hours ago, mathijs727 said:

So you have PHP code in the database that you want to execute?

Look up the "eval" command in PHP.

Second of all, please dont do this, its very dangerous.

Database compromises (which are really common with SQL injection hacks) will basically give the attacker full control over the web server.

I believe op wants to call a stored procedure from php not that procedure has php in it. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
https://linustechtips.com/topic/755422-php-programming-help/#findComment-9553425
Share on other sites

Link to post
Share on other sites

7 hours ago, mathijs727 said:

So you have PHP code in the database that you want to execute?

Look up the "eval" command in PHP.

Second of all, please dont do this, its very dangerous.

Database compromises (which are really common with SQL injection hacks) will basically give the attacker full control over the web server.

OP intends to CALL a stored procedure being stored by whatever database engine he's using. Of course, he should use prepared statements to avoid MySQL injection regardless.

 

OP:

First, make sure the databse you're using supports stored procedures.

Create a stored procedure.

Use PDO to prepare a statement for a CALL to that procedure.

Use bindValue and/or bindParam to bind arguments to the procedure.

Execute the statement.

If you've bound results, use them.

 

There's many tutorials on how to do this. I assume you know how to create procedures in SQL w/ IN/OUT params (or none, depends on what you want to do). I'd recommend something like phpMyAdmin to actually create and manage these procedures. There's many snippets you can find on StackOverflow where people are you doing what you want to achieve. As for php.net documentation, there's not a lot: http://php.net/manual/en/pdo.prepared-statements.php

And, if my thought-dreams could be seen,
they'd probably put my head in a guillotine.
But, it's alright, ma, it's life, and life only.

Link to comment
https://linustechtips.com/topic/755422-php-programming-help/#findComment-9554835
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×