I'm trying to enter data from an array ( eg entry1=(x=>y,a=b),
entry2=(x=>y,a=>c)) I'm trying to use place holders to dump the data.
It maybe late but I can't get this to work. below is the actual
routine used to exec. any idea on how to better format this.
<snippetsql statement
INSERT INTO contacts ( name_first, name_last, personal_street,
personal_city, personal_state, personal_zip, personal_phone_home,
company_phone, personal_phone_cell) VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?);
</snippet>
<snippet>
public function db_update_i($sql,$data) {
$str_check = explode(" ", $sql);
if($str_check[0] == "INSERT") {
if (is_null(db_cxn::$dbh)){
db_cxn::$dbh = self::cxn();
print 'db_cxn::db_update::a new instance of $dbh <br/>';
}
print "$sql <br/>";
$stmnt = db_cxn::$dbh->prepare($sql);
foreach ($data as $arr) {
//krumo($arr);
$i = 1;
foreach ($arr as $key =>$value){
print "$value <br/>";
$stmnt->bindParam($i, $value);
$i++;
}
$stmnt->execute();
}
$stmnt = null;
$sql = null;
return 1;
}else{
print "Error!: Incorrectly Formatted SQL Statement";
}
}
}
</snippet> 3 1885
$stmnt->bindParam($i, $value);
I'm not 100% about this, but doesn't binddParam want a data type
specified, something like:
$stmnt->bindParam($i, $value, PDO::PARAM_STR, strlen($value));
Not my usual DB library, so this is just a shot in the dark.
On Jan 7, 10:38 am, giblfiz <gibl...@gmail.comwrote:
$stmnt->bindParam($i, $value);
I'm not 100% about this, but doesn't binddParam want a data type
specified, something like:
$stmnt->bindParam($i, $value, PDO::PARAM_STR, strlen($value));
tried that, no luck. I think the problem is bindParam expects a
variable name. however I would like to just loop through the array.
This way I can use the same function to input arrays.
On Jan 6, 8:15 pm, Rowan <yaard...@gmail.comwrote:
I'm trying to enter data from an array ( eg entry1=(x=>y,a=b),
entry2=(x=>y,a=>c)) I'm trying to use place holders to dump the data.
It maybe late but I can't get this to work. below is the actual
routine used to exec. any idea on how to better format this.
figured out the problem. For reference see below I got this from the
php.net page.
If you're using bindParam in a loop such as this:
$counter=1;
foreach($email as $val){
$stmt->bindParam($counter, $val, PDO::PARAM_STR);
$counter++;
}
It will fail because $val is local and the variable is bound as a
reference and will only be evaluated at the time that PDOStatement-
>execute() is called.
So use bindValue instead. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sontu |
last post by:
Consider the following code:
int main(void)
{
char buffer;
func(buffer);
}
void func(char *bufpas)
{
|
by: arun |
last post by:
suppose i have a pointer to an array of integers.can i initialize each
member of the array using pointers?plz explain
|
by: Krish |
last post by:
Hello People
I hope I am On Topic. Anyways, here is my problem. Any insights would
be really appreciated.
I have wrapped a C IO module using SWIG -> Python Module. Suppose the
name of the...
|
by: Skay |
last post by:
Someone challenged me to create a dynamic multidimensional array using
auto_ptr
http://www.gotw.ca/gotw/042.htm
Provides a good way to create a single dimensional array using an adapter.
...
|
by: mVosa |
last post by:
I have this piece of code in a funtion which is trying to retrieve the memory address of values that are stored in a 2D array, using pointers...Could I get help or tips on how to do this please...
|
by: geervani |
last post by:
hello,
Can anybody just tell me how to scan or input a 2d array using pointer i e indirect reference. I am allocating memory the array dynamically.
the statement i am using is
int *a;...
|
by: boss1 |
last post by:
hellow everyone,
i m a new php web developer.
i got a problem. i m using innerHtml and html Dom to retrieve some data from oracle database and view on to html page.But i dont know how to insert...
|
by: SM |
last post by:
Hello,
I have an array that holds images path of cd covers. The array looks
like this:
$cd = array(
589=>'sylver.jpg',
782=>'bigone.jpg',
158=>'dime.jpg'
);
|
by: wilco |
last post by:
Hi, I want to copy a csv file into an array using fscanf and keep the blank spaces in the csv file rather than just skip over them to the next number.
there are too many spaces in the csv file to...
|
by: anandmms |
last post by:
Hello friend,
my problem is to save more than one fingerprint images in one byte array and then store in database(oracle).
i dont know how to solve it. But previously i had did image saving...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |