Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,445 members, 7,808,592 topics. Date: Thursday, 25 April 2024 at 01:56 PM

Is This Code Logical? Function Parameters Insert Statement - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Is This Code Logical? Function Parameters Insert Statement (1089 Views)

Java Programmers ,I Need Help Fixing This Code. / Please Someone Should Help Me With This Code. / PHP Code To Insert And Retrieve Images From Mysql Server (2) (3) (4)

(1) (Reply) (Go Down)

Is This Code Logical? Function Parameters Insert Statement by uvalued(m): 6:09pm On Aug 04, 2016
Note: Using mysql is deliberate but will convert it to pdo.

Am trying to use INSERT statement in a function and send data as parameters which should be inserted into the database.

I ran the codes below but it failed ....

is it a correct way of running such?
summary($no112m,$name112m,$remark112m);


function summary($no,$name,$remark)
{
$query2 = "insert INTO summary
(
sn,
no,
name,
grade
) ".
"VALUES
( '',
'$no',
'$name',
'$remark'

)";
begin();// transaction begins
$result = mysql_query($query2);
if($result){
commit();
// transaction rolls back
echo "COMMITTED 112";

}else
{
rollback();
echo "Transacton failed 112";
exit;

}

}
Re: Is This Code Logical? Function Parameters Insert Statement by Nobody: 8:35pm On Aug 04, 2016
uvalued:
Note: Using mysql is deliberate but will convert it to pdo.

Am trying to use INSERT statement in a function and send data as parameters which should be inserted into the database.

I ran the codes below but it failed ....

is it a correct way of running such?



1) You should run a function after declaration...
2) It seems you have syntax errors in your Insert statement,
3) Mysql is deprecated, use mysqli instead.
4) exit is an inbuilt function, so you should use exit() instead.

The logic is OK, take a look at code igniter.. A PHP framework that eases development
Re: Is This Code Logical? Function Parameters Insert Statement by Codenister: 9:33pm On Aug 04, 2016
Well, I didn't really take time out to study the correctness of your code, but I can tell you what you have done is logically correct.
Also, I'm assuming in your proper code, you will declare the function before invoking it.
Re: Is This Code Logical? Function Parameters Insert Statement by uvalued(m): 7:17am On Aug 05, 2016
DanielTheGeek:


1) You should run a function after declaration...
2) It seems you have syntax errors in your Insert statement,
3) Mysql is deprecated, use mysqli instead.
4) exit is an inbuilt function, so you should use exit() instead.

The logic is OK, take a look at code igniter.. A PHP framework that eases development

thanks a lot... i got it working...on cogeigniter, i have this laziness to learn becos of ? i just lay my finger on it solidly...in your opinion what is that simple thread that makes it thick..a little push may give me some good light
Re: Is This Code Logical? Function Parameters Insert Statement by uvalued(m): 7:18am On Aug 05, 2016
Codenister:
Well, I didn't really take time out to study the correctness of your code, but I can tell you what you have done is logically correct.
Also, I'm assuming in your proper code, you will declare the function before invoking it.
thanks got it working
Re: Is This Code Logical? Function Parameters Insert Statement by furthest(m): 4:36pm On Aug 07, 2016
Codenister:
Well, I didn't really take time out to study the correctness of your code, but I can tell you what you have done is logically correct.
Also, I'm assuming in your proper code, you will declare the function before invoking it.
talking about functions an invocation..pls can i call functions directly 4rm my my operating system?

(1) (Reply)

I Need A Programmer To Help Build An E-commerce Website / Full 34hours Course Videos + Exercise Fill And Software For Web Design / How To Build Email List Via Email Marketing

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.