Multiple Update

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Multiple Update

Post by Erick020 »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I would like to insert and then update several data at the same time in a database.

I have this querry I run to get the page on which I run then the "insert / update" querry:

Code: Select all

$q = "select * from TABLE_0
   
  WHERE Sold = 'NO'
  AND Zip LIKE '$Zip1$Zip2%'
   ORDER BY Date asc
   LIMIT $Leads_H ";   
             
 if(!($res = mysql_DB_query($DB, $q)))
           die("ERROR");
              
           $res = mysql_db_query($DB, $q);
        $numberOfRows=mysql_num_rows($res);

while ($i > $Leads_H) {
$Q_ID=mysql_result($res,$i,"Q_ID");
echo "<input type='hidden' name='".$r["Q_ID"]."' value=Q_ID[$i]>";

}
        while ($r=mysql_fetch_array($res)){  
        $Q_ID = $_POST[Q_ID][$i];
     
        echo "<input type=hidden name=Q_ID[$i] value=".$r["Q_ID"].">
           <td align=left class=black>".$r["Name"]."</td>
           <td align=left class=black>".$r["Zip"]."</td>";
++$i;

}

echo "<a href=Command.php>ORDER</a>";
NOTE : THIS WORKS OK, I GET <input type=hidden name=Q_ID[0] value=6>
<input type=hidden name=Q_ID[1] value=9>
<input type=hidden name=Q_ID[2] value=17>

On the next script (Command.php) I run:

Code: Select all

$q ="insert into TABLE_1 (Company_Name, A2, A3) values ('$Company_Name', '$A2', '$A3')";
and then I need to update an other table:

Code: Select all

$q = "update TABLE_0 set Sold='YES',Company_Name='$A'
   
   WHERE
   
   'Q_ID[$i]' = 'Q_ID[$i]' LIMIT $Leads_H";echo $q;
   
   while ($r=mysql_fetch_array($res)){  
        $Q_ID = $_POST[Q_ID][$i];
        }
This part doesn't work.
I do not get any ERROR but this querry updates the first X rows ($Leads_H) in the table... without considering the ID of the chosen data.

It seems it doesn't recognize the ID of Q_ID
In my exemple:
<input type=hidden name=Q_ID[1] value=9>
<input type=hidden name=Q_ID[2] value=17>
it supposes to update Q_ID where the ID is 9 and 17...

Is anybody there who can help me please?


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Multiple Update - HELP NEEDED PLEASE - URGENT

Post by volka »

[url=http://de2.php.net/mysql_db_query wrote:http://de2.php.net/mysql_db_query[/url]"]mysql_db_query
[...]
This function is deprecated, do not use this function. Use mysql_select_db() and mysql_query() instead.
Erick020 wrote:$q = "update TABLE_0 set Sold='YES',Company_Name='$A'

WHERE

'Q_ID[$i]' = 'Q_ID[$i]' LIMIT $Leads_H";echo $q;

while ($r=mysql_fetch_array($res)){
$Q_ID = $_POST[Q_ID][$i];
}
I don's see a mysql_query or mysql_db_query here.
An UPDATE query does not return a result set, $r would be true or false, nothing you can pass to mysql_fetch_array.
What does echo $q; print?
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Re: Multiple Update - HELP NEEDED PLEASE - URGENT

Post by Erick020 »

volka wrote:
[url=http://de2.php.net/mysql_db_query wrote:http://de2.php.net/mysql_db_query[/url]"]mysql_db_query
[...]
This function is deprecated, do not use this function. Use mysql_select_db() and mysql_query() instead.
Erick020 wrote:$q = "update TABLE_0 set Sold='YES',Company_Name='$A'

WHERE

'Q_ID[$i]' = 'Q_ID[$i]' LIMIT $Leads_H";echo $q;

while ($r=mysql_fetch_array($res)){
$Q_ID = $_POST[Q_ID][$i];
}
I don's see a mysql_query or mysql_db_query here.
An UPDATE query does not return a result set, $r would be true or false, nothing you can pass to mysql_fetch_array.
What does echo $q; print?

First thank you for your reaction.

Well, I use to run the update querry always like that and it works, but only for one row.
Now I must update several rows where the IDs have been selected.

The selected data : <input type=hidden name=Q_ID[1] value=9>, input type=hidden name=Q_ID[2] value=17>...

and I must run 2 querry: first an INSERT QUERRY in TABLE_1 and an UPDATE QUERRY in TABLE_0

The INSERT is OK.
The update suppose to update the selected rows (9, 17,...)
but it updates only the first X rows in the table without considering the ID of the chosen data.

Just tell me the right querry to update specific selected rows (<input type=hidden name=Q_ID[1] value=9>) from there.

Thank you very much.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Multiple Update - HELP NEEDED PLEASE - URGENT

Post by volka »

It won't work until there is a mysql_db_query or mysql_query to send the UPDATE query to the mysql server, it simply won't Where is it? Please show me the real code.
And what's the output of echo $q;?
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Re: Multiple Update - HELP NEEDED PLEASE - URGENT

Post by Erick020 »

volka wrote:It won't work until there is a mysql_db_query or mysql_query to send the UPDATE query to the mysql server, it simply won't Where is it? Please show me the real code.
And what's the output of echo $q;?
I sent you a personal Msg.

the output is empty [].
echo $q = WHERE 'Aanvraag_ID[]' = 'Aanvraag_ID[]' LIMIT 3
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Multiple Update - HELP NEEDED PLEASE - URGENT

Post by volka »

Erick020 wrote:I sent you a personal Msg.
And I've deleted it unread, no need for mystery.
Please post your real code, not something you've made up for the forum.
Please post the real ouput, copy&paste.
And please use

Code: Select all

tags for posting script code and [quote] tags for posting the copy&paste output.


this post might sound a bit harsh   ...and that's intentional
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Re: Multiple Update - HELP NEEDED PLEASE - URGENT

Post by Erick020 »

volka wrote:
Erick020 wrote:I sent you a personal Msg.
And I've deleted it unread, no need for mystery.
Please post your real code, not something you've made up for the forum.
Please post the real ouput, copy&paste.
And please use

Code: Select all

tags for posting script code and [quote] tags for posting the copy&paste output.


this post might sound a bit harsh   ...and that's intentional [/quote][/quote]

I sent you the real code... if you want I can send you the file !

This is the real code:

The first script (output selected rows):

Code: Select all

$q = "select * from HYPOTHEEK 
   
  WHERE Sold = 'NO'
  AND Zip LIKE '$Zip1$Zip2%'
   ORDER BY Date_Aanvraag asc
   LIMIT $Leads_H
   
              ";
 
		
              if(!($res = mysql_DB_query($DB, $q)))
           die("ERROR");
          	 
           
           $res = mysql_db_query($DB, $q);
        $numberOfRows=mysql_num_rows($res);

       
while ($i > $Leads_H) {
$Aanvraag_ID=mysql_result($res,$i,"Aanvraag_ID");
echo "<input type='hidden' name='".$are["Aanvraag_ID"]."' value=Aanvraag_ID[$i]>";

}


        while ($r=mysql_fetch_array($res)){  
        $Aanvraag_ID = $_POST[Aanvraag_ID][$i];
        $var++;
        
  echo "<head>
<title>LEADS</title>
<link rel=stylesheet href=Erick.css>
</head>
<body leftmargin=0 topmargin=0>
<table width=800 border=1 cellspacing=5 cellpadding=5 align=center>
  
  <input type=hidden name=Aanvraag_ID[$i] value=".$r["Aanvraag_ID"].">
  <tr>
  <td align=right valign=middle width=25><b>$var</b></td>
    <td align=left class=black>".$r["Name"]."</td>
    <td align=center class=black width=100>".$r["Zip"]." ".$r["Zip_A"]."</td>
    <td align=center class=black width=100>".$r["Province"]."</td>
    <td align=center class=black width=150>".date("d-m-Y",$r["Date_Aanvraag"])."</td>
  </tr>

</table>

</body>
</html>";
++$i;

}

echo"<p align=center class=black><a href=Command_Leads_H.php?A=$A&&Zip1=$Zip1&&Zip2=$Zip2&&Kind=$Kind&&Leads_H=$Leads_H name=Leads_H1>ORDER BEVESTIGEN</a> - <a href=javascript:history.go(-1)>ORDER WIJZIGEN</a></p>";


The update script:

$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
    values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";echo $q;
    
 	
	
    $q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'
	
	WHERE
	
	'Aanvraag_ID[$i]' = 'Aanvraag_ID[$i]' LIMIT $Leads_H";echo $q;
	
	while ($r=mysql_fetch_array($res)){  
        $Aanvraag_ID = $_POST[Aanvraag_ID][$i];
        }
	
	if(!$dbconn){
	   die("Connection failed.");
	}else
	
	 {
		if(($res = mysql_DB_query($DB, $q))){
		
		


		echo "OK";
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Re: Multiple Update - HELP NEEDED PLEASE - URGENT

Post by Erick020 »

Erick020 wrote:
volka wrote:
Erick020 wrote:I sent you a personal Msg.
And I've deleted it unread, no need for mystery.
Please post your real code, not something you've made up for the forum.
Please post the real ouput, copy&paste.
And please use

Code: Select all

tags for posting script code and [quote] tags for posting the copy&paste output.


this post might sound a bit harsh   ...and that's intentional [/quote]

I sent you the real code... if you want I can send you the file !

This is the real code:

The first script (output selected rows):

Code: Select all

$q = "select * from HYPOTHEEK 
   
  WHERE Sold = 'NO'
  AND Zip LIKE '$Zip1$Zip2%'
   ORDER BY Date_Aanvraag asc
   LIMIT $Leads_H
   
              ";
 
		
              if(!($res = mysql_DB_query($DB, $q)))
           die("ERROR");
          	 
           
           $res = mysql_db_query($DB, $q);
        $numberOfRows=mysql_num_rows($res);

       
while ($i > $Leads_H) {
$Aanvraag_ID=mysql_result($res,$i,"Aanvraag_ID");
echo "<input type='hidden' name='".$are["Aanvraag_ID"]."' value=Aanvraag_ID[$i]>";

}


        while ($r=mysql_fetch_array($res)){  
        $Aanvraag_ID = $_POST[Aanvraag_ID][$i];
        $var++;
        
  echo "<head>
<title>LEADS</title>
<link rel=stylesheet href=Erick.css>
</head>
<body leftmargin=0 topmargin=0>
<table width=800 border=1 cellspacing=5 cellpadding=5 align=center>
  
  <input type=hidden name=Aanvraag_ID[$i] value=".$r["Aanvraag_ID"].">
  <tr>
  <td align=right valign=middle width=25><b>$var</b></td>
    <td align=left class=black>".$r["Name"]."</td>
    <td align=center class=black width=100>".$r["Zip"]." ".$r["Zip_A"]."</td>
    <td align=center class=black width=100>".$r["Province"]."</td>
    <td align=center class=black width=150>".date("d-m-Y",$r["Date_Aanvraag"])."</td>
  </tr>

</table>

</body>
</html>";
++$i;

}

echo"<p align=center class=black><a href=Command_Leads_H.php?A=$A&&Zip1=$Zip1&&Zip2=$Zip2&&Kind=$Kind&&Leads_H=$Leads_H name=Leads_H1>ORDER BEVESTIGEN</a> - <a href=javascript:history.go(-1)>ORDER WIJZIGEN</a></p>";


The update script:

$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
    values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";echo $q;
    
 	
	
    $q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'
	
	WHERE
	
	'Aanvraag_ID[$i]' = 'Aanvraag_ID[$i]' LIMIT $Leads_H";echo $q;
	
	while ($r=mysql_fetch_array($res)){  
        $Aanvraag_ID = $_POST[Aanvraag_ID][$i];
        }
	
	if(!$dbconn){
	   die("Connection failed.");
	}else
	
	 {
		if(($res = mysql_DB_query($DB, $q))){
		
		


		echo "OK";
I forgot the $q echo:

insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime) values ('87', 'HYPOTHEEK', '4', 'NO', '1180199173')update HYPOTHEEK set Sold='YES',Company_Name='87', Date_Sold='1180199173' WHERE 'Aanvraag_ID[]' = 'Aanvraag_ID[]' LIMIT 4
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please try

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
	values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";
echo '<div>Debug INSERT statement', htmlentities($q), "</div>\n";
// $q is never sent to the mysql server, therefore the INSERT statement is not executed
   
$q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'
	WHERE
		'Aanvraag_ID[$i]' = 'Aanvraag_ID[$i]' LIMIT $Leads_H
";
echo '<div>Debug UPDATE statement', htmlentities($q), "</div>\n";
       
// what's this while loop supposed to do? What is $r?
while ($r=mysql_fetch_array($res)){ 
	$Aanvraag_ID = $_POST[Aanvraag_ID][$i];
}
       
if(!$dbconn) {
	die("Connection failed.");
}
else
{
	// here you are sending $q to the mysql server
	// $q is still the UPDATE statement. The INSERT statement anyway is lost.
	if(($res = mysql_DB_query($DB, $q))){
		echo "query was successful<br />\n";
		echo 'query was: ', $htmlenetities($q), "<br />\n";
		echo 'affected rows: ', mysql_affected_rows(), "<br />\n";
	}
	else {
		echo "query failed.<br />\n";
		echo 'query was: ', $htmlenetities($q), "<br />\n";
		echo 'error: ', mysql_error(), "<br />\n";
	}
}
and post the output
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:please try

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
	values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";
echo '<div>Debug INSERT statement', htmlentities($q), "</div>\n";
// $q is never sent to the mysql server, therefore the INSERT statement is not executed
   
$q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'
	WHERE
		'Aanvraag_ID[$i]' = 'Aanvraag_ID[$i]' LIMIT $Leads_H
";
echo '<div>Debug UPDATE statement', htmlentities($q), "</div>\n";
       
// what's this while loop supposed to do? What is $r?
while ($r=mysql_fetch_array($res)){ 
	$Aanvraag_ID = $_POST[Aanvraag_ID][$i];
}
       
if(!$dbconn) {
	die("Connection failed.");
}
else
{
	// here you are sending $q to the mysql server
	// $q is still the UPDATE statement. The INSERT statement anyway is lost.
	if(($res = mysql_DB_query($DB, $q))){
		echo "query was successful<br />\n";
		echo 'query was: ', $htmlenetities($q), "<br />\n";
		echo 'affected rows: ', mysql_affected_rows(), "<br />\n";
	}
	else {
		echo "query failed.<br />\n";
		echo 'query was: ', $htmlenetities($q), "<br />\n";
		echo 'error: ', mysql_error(), "<br />\n";
	}
}
and post the output
WHICH OUTPUT?!

I run the update script and that's it !

The output of this script is:
insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime) values ('87', 'HYPOTHEEK', '4', 'NO', '1180199706')update HYPOTHEEK set Sold='YES',Company_Name='87', Date_Sold='1180199706' WHERE 'Aanvraag_ID[]' = 'Aanvraag_ID[]' LIMIT 4

NO ERROR... but the brakkets are empty.... so no update, only insert.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Why do I have such a hard time to believe that?
Wait... it's the missing Debug INSERT statement in the output for starters.
volka wrote:echo '<div>DebugINSERT statement', htmlentities($q), "</div>\n";
Same for the UPDATE statement.
You've either edited the output. Or you didn't run the script. Or you ran the wrong script.
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:Why do I have such a hard time to believe that?
Wait... it's the missing Debug INSERT statement in the output for starters.
volka wrote:echo '<div>DebugINSERT statement', htmlentities($q), "</div>\n";
Same for the UPDATE statement.
You've either edited the output. Or you didn't run the script. Or you ran the wrong script.
This is the output, but note the INSERT QUERRY WORKS VERY WELL.

Notice: Undefined variable: i in /var/www/vhosts/Command_Leads_H.php on line 19

Notice: Undefined variable: i in /var/www/vhosts/Command_Leads_H.php on line 19

Debug UPDATE statementupdate HYPOTHEEK set Sold='YES',Company_Name='87', Date_Sold='' WHERE 'Aanvraag_ID[]' = 'Aanvraag_ID[]' LIMIT 3

but I guess you know what I want to do, so if you know a better way, please just send the (part of the) script I should change.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Erick020 wrote:This is the output, but note the INSERT QUERRY WORKS VERY WELL.
Not in this code snippet, it can't be.
Can it be that the $q = "INSERT ..." statement is superfluous in the code snippet we're talking about.
Erick020 wrote:The update script:

$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";echo $q;



$q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'
Again, it impossible that this INSERT statement is executed. Ask someone else if you want, it's not possible - never ever. Do you want an insert statement exactly there or have you just copied the code and forgot the insert statement string?

What about the

Code: Select all

if(!$dbconn) {
        die("Connection failed.");
}
else
{
        // here you are sending $q to the mysql server
        // $q is still the UPDATE statement. The INSERT statement anyway is lost.
        if(($res = mysql_DB_query($DB, $q))){
                echo "query was successful<br />\n";
                echo 'query was: ', $htmlenetities($q), "<br />\n";
                echo 'affected rows: ', mysql_affected_rows(), "<br />\n";
        }
        else {
                echo "query failed.<br />\n";
                echo 'query was: ', $htmlenetities($q), "<br />\n";
                echo 'error: ', mysql_error(), "<br />\n";
        }
}
part? There's no output at all?
Erick020
Forum Newbie
Posts: 22
Joined: Sat Apr 12, 2003 7:11 am

Post by Erick020 »

volka wrote:
Erick020 wrote:This is the output, but note the INSERT QUERRY WORKS VERY WELL.
Not in this code snippet, it can't be.
Can it be that the $q = "INSERT ..." statement is superfluous in the code snippet we're talking about.
Erick020 wrote:The update script:

$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";echo $q;



$q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'
Again, it impossible that this INSERT statement is executed. Ask someone else if you want, it's not possible - never ever. Do you want an insert statement exactly there or have you just copied the code and forgot the insert statement string?

What about the

Code: Select all

if(!$dbconn) {
        die("Connection failed.");
}
else
{
        // here you are sending $q to the mysql server
        // $q is still the UPDATE statement. The INSERT statement anyway is lost.
        if(($res = mysql_DB_query($DB, $q))){
                echo "query was successful<br />\n";
                echo 'query was: ', $htmlenetities($q), "<br />\n";
                echo 'affected rows: ', mysql_affected_rows(), "<br />\n";
        }
        else {
                echo "query failed.<br />\n";
                echo 'query was: ', $htmlenetities($q), "<br />\n";
                echo 'error: ', mysql_error(), "<br />\n";
        }
}
part? There's no output at all?
Look, you can see in the $q echo, the INSERT is OK... all values are present...:
insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime) values ('87', 'HYPOTHEEK', '3', 'NO', '1180203353')
so, this is 100% OK.
but never mind, this is NOT important....
I must update an other table (HYPOTHEEK), and put in it the company_ID (87) the date ('1180203353') in the selected arrays (Aanvraag_ID) I get from the first script:

$q = "select * from HYPOTHEEK

WHERE Sold = 'NO'
AND Zip LIKE '$Zip1$Zip2%'
ORDER BY Date_Aanvraag asc
LIMIT $Leads_H

";
echo"<input type=hidden name=Aanvraag_ID[$i] value=".$r["Aanvraag_ID"].">";
echo"><a href=Command_Leads_H.php?A=$A&&Zip1=$Zip1&&Zip2=$Zip2&&Kind=$Kind&&Leads_H=$Leads_H name=Leads_H1>ORDER BEVESTIGEN</a> - <a href=javascript:history.go(-1)>ORDER WIJZIGEN</a>";

but somehow, the $i is not sent, and the querry cannot update the right arrays
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Erick020 wrote:
volka wrote:
Erick020 wrote:This is the output, but note the INSERT QUERRY WORKS VERY WELL.
Not in this code snippet, it can't be.
Can it be that the $q = "INSERT ..." statement is superfluous in the code snippet we're talking about.
Erick020 wrote:The update script:

$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";echo $q;



$q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'
Again, it impossible that this INSERT statement is executed. Ask someone else if you want, it's not possible - never ever. Do you want an insert statement exactly there or have you just copied the code and forgot the insert statement string?

What about the

Code: Select all

if(!$dbconn) {
        die("Connection failed.");
}
else
{
        // here you are sending $q to the mysql server
        // $q is still the UPDATE statement. The INSERT statement anyway is lost.
        if(($res = mysql_DB_query($DB, $q))){
                echo "query was successful<br />\n";
                echo 'query was: ', $htmlenetities($q), "<br />\n";
                echo 'affected rows: ', mysql_affected_rows(), "<br />\n";
        }
        else {
                echo "query failed.<br />\n";
                echo 'query was: ', $htmlenetities($q), "<br />\n";
                echo 'error: ', mysql_error(), "<br />\n";
        }
}
part? There's no output at all?
Erick020 wrote:Look, you can see in the $q echo, the INSERT is OK... all values are present...:
insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime) values ('87', 'HYPOTHEEK', '3', 'NO', '1180203353')
so, this is 100% OK.
but never mind, this is NOT important....
Ok, let me try it another way. What do you think is the purpose of mysql_query() or mysql_db_query()? What does it do? And therefore what happens if it isn't present?
Post Reply