Click here to Skip to main content
15,885,546 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: JSON response from PHP for ajax Pin
jaypatel5127-Nov-10 8:47
jaypatel5127-Nov-10 8:47 
AnswerRe: JSON response from PHP for ajax Pin
nickmaroulis20-Nov-10 10:00
nickmaroulis20-Nov-10 10:00 
QuestionCoverting PDF to HTML Pin
sarang_k1-Nov-10 20:48
sarang_k1-Nov-10 20:48 
AnswerRe: Coverting PDF to HTML Pin
Dr.Walt Fair, PE3-Nov-10 5:43
professionalDr.Walt Fair, PE3-Nov-10 5:43 
AnswerRe: Powershell question: How to print only the current folder name Pin
Sauro Viti27-Oct-10 0:17
professionalSauro Viti27-Oct-10 0:17 
AnswerRe: Powershell question: How to print only the current folder name Pin
Peter_in_278027-Oct-10 0:18
professionalPeter_in_278027-Oct-10 0:18 
GeneralRe: Powershell question: How to print only the current folder name Pin
melwyn27-Oct-10 0:22
melwyn27-Oct-10 0:22 
QuestionMySQL syntax error near '' Pin
nathionice25-Oct-10 21:10
nathionice25-Oct-10 21:10 
Hi
Thanks in advance for helping me. I have this mySQL query that fails i have no idea why i. Below is the code I left some space for readability




$lines=file("somefile5640.001");
$headerTable=explodeX(Array(",","\n"),$lines[0]);
$table ="HeaderRecord";

WriteArrayToHeaderDatabase($headerTable,$table);

function WriteArrayToHeaderDatabase($headerTable,$table)//Pass which table am i writing to
{

//I do the connecting to database here which is fine the problem is below

$query = "INSERT INTO ".$table."(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES";

for($i = 0, $c = count($headerTable); $i < $c; $i += 6) {
// Add the next batch of values to the query string
$query.= "('".$headerTable[$i]."','".$headerTable[$i+1]."','".$headerTable[$i+2]."','".$headerTable[$i+3]."','".$headerTable[$i+4]."','".$headerTable[$i+5]."')";
//$query .= "(".$headerTable[$i].",".$headerTable[$i+1].",".$headerTable[$i+2].",".$headerTable[$i+3].",".$headerTable[$i+4].",".$headerTable[$i+5].")";
echo "Query is failing";

// Add a comma is this is not the last batch
if($i + 1 < $c) {
//$query .= "";
$query .=",";
}

echo $query;
$result = mysql_query($query);

if (!$result) {
die('Query failed: ' . mysql_error());
}

}
return true;


// When i echo the query and run the code i get what shown below

Query is failingINSERT INTO HeaderRecord(FileIdentifier, Version, ReceiverIdentifier, Date, Time, FileGenerationNumber) VALUES('SOF','1','1500','19970519','112904','1 '),Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
AnswerRe: MySQL syntax error near '' Pin
Geoff Williams25-Oct-10 22:28
Geoff Williams25-Oct-10 22:28 
GeneralRe: MySQL syntax error near '' Pin
Gerben Jongerius26-Oct-10 1:08
Gerben Jongerius26-Oct-10 1:08 
GeneralRe: MySQL syntax error near '' Pin
nathionice26-Oct-10 1:55
nathionice26-Oct-10 1:55 
GeneralRe: MySQL syntax error near '' Pin
Gerben Jongerius26-Oct-10 3:36
Gerben Jongerius26-Oct-10 3:36 
GeneralRe: MySQL syntax error near '' Pin
nathionice26-Oct-10 5:00
nathionice26-Oct-10 5:00 
GeneralRe: MySQL syntax error near '' Pin
Gerben Jongerius26-Oct-10 20:34
Gerben Jongerius26-Oct-10 20:34 
AnswerRe: MySQL syntax error near '' Pin
Graham Breach26-Oct-10 2:57
Graham Breach26-Oct-10 2:57 
AnswerRe: MySQL syntax error near '' Pin
cjoki26-Oct-10 5:04
cjoki26-Oct-10 5:04 
GeneralRe: MySQL syntax error near '' Pin
nathionice26-Oct-10 5:42
nathionice26-Oct-10 5:42 
GeneralRe: MySQL syntax error near '' Pin
Gerben Jongerius26-Oct-10 20:29
Gerben Jongerius26-Oct-10 20:29 
GeneralRe: MySQL syntax error near '' Pin
nathionice26-Oct-10 20:53
nathionice26-Oct-10 20:53 
GeneralRe: MySQL syntax error near '' Pin
cjoki27-Oct-10 5:50
cjoki27-Oct-10 5:50 
Questionhello about Cacti Pin
lxlenovostar19-Oct-10 2:38
lxlenovostar19-Oct-10 2:38 
AnswerRe: hello about Cacti Pin
cjoki19-Oct-10 4:39
cjoki19-Oct-10 4:39 
Questioni catch a problem when i compiling Pin
lxlenovostar18-Oct-10 3:03
lxlenovostar18-Oct-10 3:03 
AnswerRe: i catch a problem when i compiling Pin
Iranian MM8-Sep-11 5:30
Iranian MM8-Sep-11 5:30 
Questionproblem in windows 7 Pin
mstanwar13-Oct-10 14:46
mstanwar13-Oct-10 14:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.