PDA

View Full Version : $query INSERT INTO not executing ???


vosgien
08-31-2004, 05:19 PM
***EDIT***
resolved the prob by running the code seperately
and discovered a prob in my db columns - all fixed now Cheers
***END EDIT***

Hi,
I have a php file called upload.php which retrieves a bunch of variables ( user input) from an HTML page, the upload.php runs a series of checks to ascertain that the vars exist, email authentification, file upload errors etc etc, this works OK, probably better if I explain the next bit with code :

//last line in upload.php is...

include("dbDetails.php");
?>
// dbDetails.php looks like this

<?php
include("connect.php");
/*connect contains passwords and db name etc etc
and has been checked and works OK*/

/*check to see if new client or existing*/
if(!isset($clientID)||empty($clientID))
{
include ("Cid.php");
/*Cid.php takes the first letter from two variables plus
a randomly produced number to give me var $clientID*/

$noJobs = 1;

/* if client ID is empty this means we have a new client
and want to enter the client details into a table called 'clients'*/
$query = "INSERT INTO clients(clientID,coName,location,name,email,teleph one,ipAddy,noJobs,payMethod)";
$query.= "VALUES('$clientID','$coName','$location','$name',' $email','$telephone','$ipAddy','$noJobs','$payMeth od')";
$result = mysql_query($query);
if($result)
{
echo "details entered";
}
}
else
{
/*if an existing client I just need to UPDATE the table 'clients'*/
/*update code in here*/
echo "client number exists";
}
/*the above block of code works fine - the problem is with the next block

whether the client is new or existing I need to insert into table 'translations'
information about the job - however the next block of code is totally
ignored and no entry is made into the db !!!*/

$query = "INSERT INTO $tableT(clientID,userfile_name,subject,selectLang, wordCt,deadline,dateUpload)";
$query.= "VALUES('$clientID','$userfile_name','$subject','$s electLang','$wordCt','$deadline','$dateUpload')";
$result = mysql_query($query);
if($result)
{
echo "details entered 2";
}

mysql_close($link);

?>


So the second INSERT is ignored completely, whilst everything else runs smoothly, I cannot find any parse errors, I have run error checking code etc etc and cannot find a problem at all
I am wondering if I need to use something like prepare, but I have no idea how ?
Or perhaps the Q should be : can I run two INSERT queries like this, and if not, how can I change the code to ensure the 2nd insertion

Cheers

Vosgien