Using Session Variables To Insert Data To MYSQL Database?

May 23, 2009

I am having problems getting PHP to insert data into a MYSQL data base. I am using the following variations of syntax.

mysql_query("INSERT INTO table member VALUES ('$var1', '$var2', '$var3')")
or die("couldn't add new user");

and also with session variables as well

mysql_query("INSERT INTO table member VALUES ('$_SESSION[$var1]', '$_SESSION[$var2], '$_SESSION[$var3]')")or die("couldn't add new user");

i have put all these through a print statement to make sure the variables ae set and they print in the same block of code so i have no idea what i am doing wrong.?

ADVERTISEMENT

Code Insert To View Session Variables ?

Mar 1, 2003

I am having some challenges using session variables between pages with Dreamveaver MX. Is there a piece of code i can temporarily place into my pages that will print the values of all Session Variables, such that I can see they are definately being passed between the pages?

View 2 Replies View Related

Insert Only Non Empty Values In Mysql From List Of Variables

Feb 9, 2010

i want to insert non empt values (as $im1, $im2.....) in mysql database, code is as follow, im_id is auto_increment key

$im1 =image1['image'];
$im2 =image2['image'];
$im3 =image3['image'];
$im4 =image4['image'];
$sql = "INSERT INTO `class-ads`.`images`
(im_id, image)
[Code]....

View 4 Replies View Related

Session Variables From Mysql, Get Them All At Once?

Jul 26, 2005

I'm making a new site and am wondering about the best way to query a mysql server.. basically most of the site's pages will display some type of dynamic content based on the user, and im not sure which approach is better.. should i grab all the info i need at login to put into session variables? or should i have queries when/if i need to display the info... im leaning towards getting it all once so the sites main functionality is smoother.. anyone know if im about to make a mistake?

View 1 Replies View Related

MySQL And PHP Session Variables

Jul 16, 2005

The following 3 mysql/php statements are used in my home page to
access my admin table:

$php_linkID = mysql_pconnect("localhost","user","pw");
mysql_select_db("test_db",$php_linkID);
$php_resultID = mysql_query("SELECT * FROM admin", $php_linkID);

On another web page I try to use another table in the same database
but I get an error on the if statement - I've saved the $php_linkID as
a session variable from the home page thinking I can just use it here
on a different web page - is this not possible?

$php_resultID = mysql_query("UPDATE controls SET screen_width =
frm_screen_width WHERE id = $php_session_member_name, $php_linkID);
if ($php_resultID != FALSE) <------ errors here
{
print "Database update error - Changes not made.";
}
else
{
print "My Controls successfully updated!";
}

View 3 Replies View Related

Using Session Variables In Mysql Queries

Jul 2, 2007

My php code consists of getting a person's session_id() and placing that in a session variable for use in other pages.

The thing is, though, that when i place a session variable in a mysql query, i get the following error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/e/r/i/ericjacobson01/html/index.php on line 11

This is the part that php complains about:

$_SESSION['buyer_id'] = session_id();

$istableset = mysql_query("SELECT * FROM ' .$_SESSION['buyer_id'] '");

View 5 Replies View Related

Set Session Variables From Records In A MySql Database

Mar 19, 2004

I am working on a memebship section for a website and I am trying to set session variables from records in a MySql database when the user logs in. I think I am missing something because try as I might the just don't work!

The sever I use had Glabal variables turned on, dont know if thats an issue in this case.

Heres the code on the check user page:

View 1 Replies View Related

Access Session Variables In /ext/mysql Extension?

Sep 1, 2010

I have declared a structure that look like

typedef struct{
char* key;
char* value;
[code]...

Now in the session_start I have initialised the values for the pair variable and I have to access these values in /ext/mysql extension.

View 1 Replies View Related

Retrieve MySql Data And Store In Session Variables?

Jul 19, 2011

I feel like I'm blowing this forum up today with random topics but I really don't want to throw it all in one post after the questions have been answered.That being said, I think I'm down to my last question of the day...My session stuff is finally working....yay!....but I have one last question...I know I can assign session['name'] with = and a direct quote but I'm having problems getting the query data to populate correctly...so this raises two questions with me...1. in my_sql, the array should start at 0, right?2. When I'm assigning the values to my session variables, how limited are my options? Are these variables standard or can I make them up as I go? meaning if I were to use $_SESSION['name'] or $_SESSION['username'] to assign the users name to, from the db, would i be able to get the same result?

mysql_connect("mysql.info",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM vis_master_links WHERE linktype=1 ORDER BY linktype, linkorder";
[code]....

View 3 Replies View Related

Warning: Session_start() [function.session-start]: Cannot Send Session Cookie - Problems With The Session Variables.

May 7, 2003

I am have a form on the page registration.html the content is posted to a page called registration.php Although the database is getting populated, i am having problems with the session variables. I get the following errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /usr/shared/web/intocore/registration.php:10) in /usr/shared/web/intocore/registration.php on line 41 Code:

View 1 Replies View Related

Session Problem: Session Exists, But Session Variables Don't Lasts

Jul 17, 2005

I have some troubles with session variables. I can easily create a session,
but the variable I append to global session array ( $_SESSION) lasts only
until the end of current function.

I prepared an example that can demonstrate the problem (see code bellow):
The program flow is this:
(1) It starts with "session_start()" and displays "login_form()".
(2) When user enters his username and password, it goes to "login()"
function which sets $_SESSION variables.
(3) This function also "Echoes" session_id and user name to the screen.
(4) Then it goes to "MyProgram()" function. It only "Echoes" the same
variables to the screen.

Strange is, that the session_id is the same in (3) and (4), but the user
name ($_SESSION["username"]) is only in (3), but not in (4). By other
words - $_SESSION["username"] variable filled up by "login()" function is
immediately cleared.

I don't know why.

There must be something missing, but after 3 days of watching it, I can not
find a problem here.

===========================================
<?
Function login($uzivatel, $heslo)
{
$_SESSION["username"] = $uzivatel;
$_SESSION["pass"] = $heslo;
$U_Name=$_SESSION['username'];
echo "Login username: $U_Name<BR>";
echo "Login session ID: ";
echo session_id();
echo "<BR>";
}

Function login_form()
{
echo ("<DIV ALIGN='center'>
<H1>Test</H1>
<P>Please enter your username and password:</P>
<form action='test.php' method='get'>
<INPUT TYPE='HIDDEN' NAME='login' VALUE=TRUE>
<TABLE BORDER=&#390;'>
<TR>
<TD ALIGN='right'><U>U</U>ser name:</TD>
<TD><INPUT NAME='uzivatel' SIZE=25 ACCESSKEY='U' TYPE='TEXT'></TD>
</TR>
<TR>
<TD align='right'><U>P</U>assword:</TD>
<TD><INPUT NAME='heslo' SIZE=25 ACCESSKEY='P' TYPE='PASSWORD'></TD>
</TR>
<TR>
<TD COLSPAN=2 ALIGN='RIGHT'><INPUT NAME='OK' ACCESSKEY='O' TYPE='SUBMIT'
VALUE='OK' TABINDEX=3></TD>
</TR>
</TABLE>
</FORM></DIV></HTML>");
}

Function MyProgram()
{
$U_Name=$_SESSION['username'];
echo "Program username: $U_Name<BR>";
echo "Program session ID: ";
echo session_id();
echo "<BR>";
}

{
session_start();
if ($_SESSION['username']):
MyProgram();
else:
{
if (!$login):
login_form(0);
else:
login($uzivatel, $heslo);
MyProgram();
endif;
}
endif;
}
?>
===========================================

View 3 Replies View Related

Session Variables Local To The User Or Does A Session Id Need To Be Different To Everyone That Visits Site?

Nov 19, 2010

My main question are session variables local to the user, or does a session id need to be different to everyone that visits your site? Right now I'm assuming they are local, but worried I'm wrong. The way I have it handled right now is the session id is the same for everyone, but if I set a session variable defining the user type between regular and admin, when the admin signs in it wouldn't change everyone's type to admin would it?

View 7 Replies View Related

Insert Query Doesn't Insert Data To Mysql Database Table?

Dec 10, 2010

i have a recipe table and ingredient table the primary key of both tables are auto increament and primary key of recipe is foreign key in ingredient. i post data from html to php.Note that my ingredient textboxes are generated dynamically and successfully post the data to php script. posted data is correct when i insert this data to table my query working fine but data is not added to mysql table. my code and output is

$sql = "insert into recipe (rec_id, Name, Overview,category, Time, Image) values ('', '$name','$overview','$category','$time','$TARGET_PATH')";
$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
$rec_id = mysql_insert_id();

[Code].....

View 5 Replies View Related

Funny Behaviour Of Cookie Variables And Session Variables?

Nov 14, 2010

I wrote a little PHP script below to demonstrate my question. Run the code below like this:[URL]You will see that the number echo'ed to your screen is always 1 digit behind the url number?! Maybe because I cant a cookie and immediately read the same cookie?

//If query string has $test, store in session, and cookie for later.
if($_GET[test]){
$_SESSION['test'] = $_GET[test];
setcookie("test", $_GET[test], time()+60*60*24*30*12*10); //10 years
}
//If user comes back later, then get $test from cookie
if (isset($_COOKIE["test"])){.......

View 3 Replies View Related

Session Handling Problems - Session Variables Not Carrying To Next Pg

May 22, 2007

i am having trouble using session variables... this code was working for a long time (6 mths) without hassles and then suddenly ... i have a problem of.

"undefined index" when i try to access the session variables on a different page than where i d set them this is the index page of the control panel where the session vars are set Code:

View 7 Replies View Related

Session Variables Not Carrying Over To Logged In Page But Session ID Is

Jan 6, 2009

I'm using PHP 4.3.9, Apache/2.0.52 I'm trying to get a login system working that registers DB values in a session where they're available once logged in. I'm losing the session variables once I'm redirected. I'm using the following code to print the session ID/values on my login form page and the redirected page:

[Code]....

This is what's printed in my browser from my login page (I just comment out the header redirect to the logged in page). This is the correct info coming from my DB as well, so all is fine at this point.

[Code]....

This is what's printed on my redirected/logged in page (when I uncomment the header/redirect). Session ID is the same, but I get no values for the individual session variables.

[Code]....

I get the following errors:

[Code]....

I have a global header.php file which my loggedIN.php does NOT call, though loggedOUT.php does - to toast the session):

[Code]....

if I comment out the header redirect on the login page, I can echo out the $_SESSION variables with the right info from the DB. Once redirected to the login page, however, they're gone/unset. Anyone have any ideas? I've spent nearly all day on this and can't say I'm any closer to figuring it out.

BTW, I recently made 2 simple test pages, one started a session, set some variables on it, had a form submit which redirected to a second page which did nothing but read/output the session vars. It all seems to work fine, I'm just having issues with something I'm doing in my main app.

View 5 Replies View Related

Save Session Variables To Database On Session Expire?

Feb 17, 2011

I am wondering if it is possible to rescue session data into a database or a file when the session expires. For example when I have a object living in my session, will the destructor be called when the session expires? how PHP handle sessions when they expire.

View 2 Replies View Related

Can't Store Session Variables -- Session Doesn't Seem To Stay

Jul 19, 2011

I'm have a login script -- works great .I have session variables -- work great

Once I hit my login_index page, everything looks great. If I then leave the login_index, my link goes from "log out" to "log in" again. I have a script stored in a separate file, checksession.php. I've put this at the top of the pages but then I run into the redirect every time i enter a page....

<?php
session_start();
if(!isset($_SESSION['userid'])){[code]...

I'm sure there is a better way to do this---would anyone know of any links by chance where I could do some better research on this?

View 3 Replies View Related

Insert The Current Timestamp Into Mysql Db Using A Php Insert Query?

May 20, 2011

In my database (mysql), i have a table with structure -username - varchar insert_time - timestamp

this table was created in mysql using the phpmyadmin tool, and for the insert_time column, i have mentioned default value as 0000-00-00 00:00:00.

Now the problem is, i have to update this default value with the current timestamp later on, using a php script.

I tried doing this -
CODE:PHP

$update_query = 'UPDATE db.tablename SET insert_time=now() WHERE username=' .$somename;

when the php script is run, it fails, and is unable to insert anything into the database.

View 3 Replies View Related

Converting Post Variables Into Session Variables

Jun 3, 2006

I have a script in which I take a whole lot of data from a number of pages of a form, compile it into one, and let the user edit it before it's eventually thrown into a SQL database. The data coming from the forms is in post, and I've created arrays of all of the fields in the form, like: Code:

View 5 Replies View Related

Session Variables Lost Between Pages Or Use Same Variables?

Jan 2, 2011

I have Wamp Server(2.2.11) with PHP(5.2.9.-2). I know I did something wrong but I didn't find myself.Before I wrote this e-mail I red many document with different search items. I test a same application with different User IDs. When I use "session.use_cookies = 0", session variables lost between pages for SAME UserID. When I use "session.use_cookies = 1", same session variables are used DIFFERENT User IDs.

My php.ini's session settings at below:

[Session]
session.save_handler = files
session.save_path = "c:/wamp/tmp"

[code]....

View 1 Replies View Related

Session Variables Interchanged With Local Variables?

Sep 23, 2010

I've encountered a very odd issue in regards to session variables and local variables in php. if I am not understanding something about sessions in php or if this is an issue with the php version my host is using.Here is a very simple code to demonstrate the weird issue:

session_start();
var_dump($kenny);
var_dump($_SESSION['kenny']);
[code]....

It looks to me like the session variable 'kenny' and local variable $kenny become aliases to one and the other after running the script more than once. hmm... I really don't think this is how session variables and local variables work in php.My web host is running php 5.2.2. When I try this exact same code on other hosts running php 5.2.1, 5.2.14 and 5.3.1, they always give me what I expect:

1st time:NULL NULL NULL string(3) "def" string(3) "abc" string(3) "def"

thereafter:

NULL string(3) "def" NULL string(3) "def" string(3) "abc" string(3) "def"

I checked the change log on php.net and didn't find anything that I can relate to that may address this issue. But like I mentioned, an earlier build (5.2.1) works ok, so that's very puzzling to me.If anyone runs any other version of php 5.2.x, please give it a try and let me know if you see the same issue.

View 1 Replies View Related

SESSION Variables Clash With Normal $ Variables?

Mar 12, 2010

Code:

session_start();
session_regenerate_id();
$_SESSION['username'] = 'steve';
$username = 'steve';

I am using these two variables in my program, but somewhere I have a bug and I'm having trouble fixing it.Is it possible for these two variables to clash in some way since they have the same name? I keep loosing the value held in $_SESSION['username'], whilst all the other $_SESSION variables remain intact.Does doing this cause ambiguity in some way?

View 1 Replies View Related

Losing Session Variables - Session.gc.divisor

Jun 14, 2006

I have a page containing a form. The page submits to itself and if the
data validates, stores the posted variables into a database and also
into a session. I then use header to redirect to another page which
fetches the variables from the session array and displays them.

All works fine on the Linux test server. However the production server
is Windoze running PHP 5. reg globals off I am intermittently losing
variables. from the session array

It's not a register globals issue - sometimes they are there sometimes
not. The only other difference I can see is the session.gc.divisor
which is set to 100

View 2 Replies View Related

Session Array (lots Of Session Variables)

Dec 21, 2006

Is it best practice when dealing wit lots of session variables. to. Insert them in array as such, because i cant see what advantage it would be.

$_SESSION['serv'] = array();
$_SESSION['date'] = $_POST['date'];
$_SESSION['service'] = $_POST['service'];

View 3 Replies View Related

Start A Session And Session Variables In Cron

Jun 26, 2007

i have a cron job setup to send out a link in a email that leads to a survey. I need to set session variables or something to hide elements needed to build the survey does anyone know how to do this I'd prefer Session or a better alternative.

I would just put the survey construction vars in the link itself and use GET but thats not very secure i dont think.

View 1 Replies View Related

MySQL INSERT- Can't Find The Insert Is Not Happening?

Nov 21, 2010

Can anyone tell me why this is not INSERTing? My array data is coming out just fine.. I've tried everything I can think of and cannot get anything to insert.. Ahhhh!

<?php
$query = "SELECT RegionID, City FROM geo_cities WHERE RegionID='135'";
$results = mysqli_query($cxn, $query);
$row_cnt = mysqli_num_rows($results);
echo $row_cnt . " Total Records in Query.<br /><br />";
if (mysqli_num_rows($results)) {
while ($row = mysqli_fetch_array($results)) {
$insert_city_query = "INSERT INTO all_illinois SET state_id=$row[RegionID], city_name=$row[City] WHERE id = null" or mysqli_error();

[Code]...

View 1 Replies View Related

Passing Variables And Session Variables

Jun 1, 2003

I'm currently working on a shopping cart script that works just fine with register_globals turned on but when turned off i get all kind of errors. The following page displays a detail of the book with the "Add to cart" link at the bottom. PHP Code:

View 2 Replies View Related

Variables That Change Session Variables

Jul 16, 2005

I'm currently writing a mulit-page form app that uses a session to
retain data from each form element in order for the user to jump
between pages, then the final data is passed to a calculation script.

However, I've noticed that if I assign a session variable to another
variable, which then performs a mathematical calculation, the session
variable changes.

i.e. $_SESSION["inflation"] = 4;

$temp_inf = $_SESSION["inflation"];
if ($_SESSION["inflation"] =="RPI") {
$inflation = $rpi;}
else {$inflation = ($temp_inf/100.0);}

now it equals = 0.04

How can I take a value from a session and perform operations on it
without altering the original session value.

View 1 Replies View Related

Can You Set FILES[] Variables To Session Variables?

Oct 17, 2006

I have some code to upload files to my site. it works when the <input
type="file" is posted once even when I use session variables from the
posted variables but when I carry those session variables to a new page the
upload will not work.

despite the variables being set. I have echoed then on
the second page and they display correctly but they just dont work in the
move_uploaded_file() function. Code:

View 7 Replies View Related

Form Variables To Session Variables

Nov 30, 2007

I am writing a small script that consists of two pages:  page one displays a bunch of values from a DB (ie. First Name, Last Name, Phone Number).  On this page you will find a form that follows this format:

<input type="text" name="edit_firstname" size="20" maxlength="35" value='Bob'>
<input type="text" name="edit_lastname" size="20" maxlength="35" value='Smith'>
<input type="text" name="edit_phone" size="20" maxlength="35" value='5552222'>

So when you see the page there will already be a 'default' value in each line (which is information extracted from a DB).  This works perfectly and has been tested thoroughly.

On the second page I have the following code:

$editfirstname = $_POST['edit_firstname'];
$editlastname = $_POST['edit_lastname'];
$editphone = $_POST['edit_phone'];

What I am trying to do is this:  the default value for edit_firstname from the form is 'Bob' by default, but the user can change this in the input field on the first page.  This value, whether changed or unchanged, should then be stored as edit_firstname and by calling up the function $_POST[''] on the second page I want to transfer the value to the variable $editfirstname. 

However, it seems that $_POST['edit_firstname'] and the other fields do not return a value at all, hence $editfirstname = '' or $editfirstname = 'NULL'.  I have never tried to do things this way before. 

View 3 Replies View Related

Insert Variables

Dec 27, 2006

I want to have a single page holding this code for a Flash mp3 player. Code:

View 2 Replies View Related

INSERT INTO Sql Using Php Variables

Apr 26, 2007

I am having difficulty getting my script to work, it seems fine and i get no error messages but no data is exported to the database(SQL)

I am trying to use variables in the INSERT INTO statement because i wish to add some sanitize functions later on. Before i began using the variables ( like this: '$_POST[comment_firstname]') for each of the columns it worked. Code:

View 4 Replies View Related

MySQL Insert Appear To Work But Not Insert Anything?

Jul 21, 2010

This is driving me crazy! I have a mysql_query call to insert a simple record:
$update = mysql_query("INSERT INTO `my_db`.`record_collection` (`record_id`, `collection_id`, `sortorder`, `active`) VALUES ('$id', $new_collection_id, 0, 1)");

When echoed out, this generates a nice little query such as:
INSERT INTO `my_db`.`record_collection` (`record_id`, `collection_id`, `sortorder`, `active`) VALUES ('A1208856984', 41, 0, 1)

Pasting this query into the MySQL command line, or into phpMyAdmin works just fine - the record is inserted. However, the above mysql_query() call doesn't seem to insert the record.

Even more bizarrely, making another mysql_query() call to try inserting the same thing again comes up with a duplicate key error, as if the record *had* been inserted. I can even do a select query immediately after the insert and pull back the instered data but it's not there when I look in the datanase or try to pull the record out on a different page. It's as is the insert is not properly committed, but there are no errors reported via mysql_error().

View 18 Replies View Related

Insert Session

Jul 17, 2005

I'm trying to insert a session id to a table but am not sure of the code Something like:

$result= MYSQL_QUERY("INSERT INTO cart (cartId)".
"VALUES ('session_id()')");

View 1 Replies View Related

Insert Data Into Variables,,,

Jun 22, 2003

How can i insert the data into variables from the tables,,,

$query = "SELECT * FROM users WHERE name = '$username'";
$result = mysql_query($query, $connection) or die('error making query');

while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$organization = $row["organization"];
$contactperson = $row["contactperson"];}

View 1 Replies View Related

Insert Into Not Working With Two Variables

Oct 13, 2010

I have no idea and there is no reason why this should not be working. im simply trying to add three variables into a database, and only one works. the other two do not work for any reason i can find.

code:
<?php
$date = date("Y-m-d"); 
$dbc = mysqli_connect('localhost', 'root', '', 'timer')
or die('Error connecting to DB');
$query = @"INSERT INTO sessions (date, user, sessiontime) VALUES ('$date', '$user', '$sessiontime')";
$user = @$_GET['user'];
[Code]......

View 2 Replies View Related

Using Session To Insert Foreign Key?

Aug 5, 2010

i am trying to use a session to insert in to the database a user_id of a user who is posting a topic in to the topic table to act as a foreign key in the topic table. but i kept getting 0 in the user_id column instead of the real userid below is my code.

<?php require_once('Connections/forum_con.php'); ?>
<?php
//initialize the session
session_start();
require_once('Connections/con_user.php');

[Code].....

View 2 Replies View Related

Insert Into Database Using Session Id

Sep 22, 2007

I have this form that I want to enter data. But I want it to read a session variable called "user_id"  And when the form is submitted it enters it in the database corresponding to the correct user_id. So I figure I needed to tweek my code to say WHERE $_SESSION["user_id"]; but I can't get the SQL statement right. Code:

View 10 Replies View Related

Insert A Null When Variables Are Empty?

May 24, 2011

I have a form that asks for name, address, company name, etc. Then I do an insert of those variables into the mySQL database. The problem is that if one of the fields is left empty, the new record in the database shows it as an empty instead of a null. What is the best way to get around this?

View 2 Replies View Related

Insert Variables Into A JSON String?

Feb 13, 2010

I am using a REST API to POST attributes to a person using json. My request body looks like this:

$requestBody = '
{
"attribute": {
"@id": "",
"@uri": "",
"person": {
"@id": "222",
[Code]....

How do I change the person id, person uri and attribute id to be variables I have already stored?

View 2 Replies View Related

Using Variables As Part Of INSERT Statement

Feb 25, 2011

I have writen some code to insert a line into a mySQL database. I have created 3 fields in the mySQL database and am passing values two them.  I can use a declared variable to pass information to the filed ID (Index filed in mySQL) but if I use a variable to pass purely text values the database is not updated. 

mysql_query( "INSERT INTO $tbl_name (category_Name, ID, test) VALUES ($category, $internalId, $category2)" );
If I replace the variables with specific text, the rows are added successfully.
mysql_query( "INSERT INTO $tbl_name (category_Name, ID, test) VALUES ('werwerwer', $internalId, 'werrr')" );

It must be something stupid, I am sure.  Full code below

[Code]....

View 3 Replies View Related

INSERT - INTO - SELECT With Concatenated Variables

May 24, 2011

I have  a simple enough code that takes information from one table and drops it into another. This is great, but I have 2a new complexities that I have been unable to code correctly.

A.  'lastname', 'firstname' on table1 need to be combined into 'name'

How & Where do I combine these strings and then pass them?

[Code]....

View 4 Replies View Related

Error When INSERT Session Value Into Table?

Jan 10, 2010

I already finish a shopping cart function, but when I create a INSERT function for check out page, I got errorthis is code of customer function page which give $_SESSION values to customer id

<?php

/*
Check if a session user id exist or not. If not set redirect
[code]......

View 1 Replies View Related

Insert Multiple Variables Into A Database Quickly

Jun 3, 2004

I've just started using PHP and have written a small script to insert 10 variables into my database, e.g:

$query = "insert into items values
('".$q1."', '".$q2."', '".$q3."', '".$q4."', '".$q5."','".$q6."', '".$q7."', '".$q8."', '".$q9."', '".$q10."')";

The problem is, I will eventually need 300 questions so I don't want to list them all individually. How can change this snippet of code so that it says something along the lines of "please insert all the variables q1-q300 into the database"?

View 1 Replies View Related

ADVERTISEMENT