Jump to content

Recommended Posts

Hi..

 

Alright, i have some problems...

I have this code where some parts of it works, and some dont...

 

Before i submit the whole code here, i would start out by just inserting what accually dont work..

 

Part one:

(The thing that dont work here is that sometimes it works - sometimes it dont? o.O)

<?php

/*
Notice:
The variables that is underneeth in this insert into
is further up in the code, but they should be just fine.
*/

 // Step 1.
 // Create a new node.
 $success = mysql_query("INSERT INTO node (
										   type, 
										   title, 
										   uid, 
										   status, 
										   language, 
										   created, 
										   changed)
  						VALUES('profil', 'TITEL', '$id', '1', 'da', '$datonu', '$datonu')")
  or die(mysql_error());
  
  // The above table have a row called "nid" which is primary and auto increment.
  
  $result = mysql_query("SELECT * FROM node WHERE uid='$id'")
  or die(mysql_error());  
  
  $row4 = mysql_fetch_array($result);
  
  $nodevid = $row4['nid'];

	// Step 2
	// Update the node, and make the vid the same as the nid.
  	$success = mysql_query("UPDATE node SET vid='$nodevid' WHERE uid='$id'")
  											or die(mysql_error());

?>

Part two:

(In this part nothing is insertet to the table at ALL)

 

<?php 

  $success = mysql_query("INSERT INTO betalinger (
										   ordreid, 
										   beskrivelse, 
										   betalingsmetode, 
										   betalingdato, 
										   pris, 
										   status, 
										   uid)
  						VALUES('$dato', '$medlemskabstype', '$betalingstype', '$dato', '$pris', '1', '$id')")
  or die(mysql_error());
  
  
$sql = "DELETE * FROM a_temp_user WHERE dato=$ordrenr";
	  $result = mysql_query($sql);
?>

 

Let me know if it looks alright and you need all code to figure it out..

 

Anyway, i hope someone can help me out...

The only thing that I can think of is you have a field that is required to be filled out and is not getting a value or it is getting a value that is not correct to what is specified. I'm guessing it probably has to do with your dates but that's just a guess. What errors are you getting?

Accually, i have just tested:

 

<?php 

mysql_connect("xxxxx", "xxxxx", "xxxxx") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());

  $success = mysql_query("INSERT INTO betalinger (
										   ordreid, 
										   beskrivelse, 
										   betalingsmetode, 
										   betalingdato, 
										   pris, 
										   status, 
										   uid)
  						VALUES('1166417089', '1', '1', '1166417089', '199500', '1', '111111111')")
  or die(mysql_error());

?>

And it works just fine..

 

So it seems like it is a bug in the script somewhere..

 

Accually my head is gettin' cracked by to many things atm - so anyone wanna do some "freelance"?

 

What you need to help me with is fixin those 2 bugs ofcource - and make the script "failsafe" after a user have sumbittet... So it runs the entire operations without breaking like it does now...

 

(And maybe you can help me with some other stuff aswell)

 

I am quite sure that if you are a good programmer, it wont take you much more than an hour or so to fix.. Maybe less...

 

Anyway, if anyone is up to it - please send me a pm asap and lets work something out.

You need to do some basic debugging:

 

1. In your first example, are there any differences in the data between the values that are being inserted, and those that aren't?

 

2. Are you certain that the variables you pass into your queries have values?  Your test worked because you manually wrote the values directly in the query.  This leads me to believe your problem is that your variables aren't actually containing any values when you attempt to insert them, and the insert is failing because you have one or more columns that cannot contain a null value.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.