Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database woes

Status
Not open for further replies.

Zuggy

Programmer
May 18, 2007
12
US
I'm trying to insert values into several tables. Here's the code and then I'll explain the problem

$intoReport = $db->Execute("INSERT INTO report (project_id, report_title, date_submitted, report_url, abstract_info, userlevel)VALUES ('$project','$report','$date','$url','$abstract','$view')");

$getReportID = $db->Execute("SELECT report_id FROM report WHERE report_title ='$report'");
//echo $getReportID;

$intoAuthor = "INSERT INTO rep_aut (report_id, author_id) VALUES ('$getReportID', '$author')";
//echo $intoAuthor;

$rs = $db->Execute($intoAuthor);


OK the the first variable $intoReport is fine it takes values from variables that are set to $_POST values and puts them into a row in the report table.

The second variable $getReportID then queries the and pulls an autonumber primary key for the row just inserted by $intoReport

The third variable is supposed to insert the number retrieved from the report and the option from select list and insert them into the rep_aut table.

The problem I'm having is that $getReportID is putting both the column name and value into the variable instead of just the variable and then since the rep_auth table is just integers it won't accept the input.

I need to know how to either strip the column name from the value or not get it into the variable to begin with (preferably the latter)

I am using ADOdb since the backend database is an Access database. Don't try to convince me to change I have no choice in the matter.
 
Zuggy said:
I am using ADOdb since the backend database is an Access database. Don't try to convince me to change I have no choice in the matter.

...At least we can tell you searched these boards before asking your question. :)

When you echo $getReportID, what is the exact output? Is it two values separated by a delimiter (like a comma) or is it an array with the column name as the key and the data as the value? That is really the only important piece of info we'll need to help you that we don't already have.

I think we're probably going to end up having to separate the two somehow. To not get the column name in the first place would take changing the return value of the method you are calling and will likely break every other script that uses that class...generally not a good thing.
 
oops I knew I forgot a vital piece of info

When I echo $getReportID it's an array with the column name as the key and the data as the value ('report_id 55')

No delimiters
 
Then how about just doing: $getReportID['columname']


Thats the way you usually access arrays? and it would only be a little change in the insert query.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top