Jump to content

mistake?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
techker

techker

    Programmer

  • Members
  • PipPipPipPip
  • 136 posts
hey guys i have ben trying to find my error in this script..it was working fine before so i mofyed some stuff saved it to many time to remeber what i did...


now it does not want to save anymore...


<?php

$client_id=$_POST['client_id'];

$montant_total_contrat=$_POST['montant_total_contrat'];

$premier_versement=$_POST['premier_versement'];

$solde_restant=$_POST['solde_restant'];

$visa=$_POST['visa'];

$mastrecard=$_POST['mastrecard'];

$amex=$_POST['amex'];

$debit=$_POST['debit'];

$cash=$_POST['cash'];

$cheque=$_POST['cheque'];

$nombre_vers_sub=$_POST['nombre_vers_sub'];

$pre_autoriser=$_POST['pre_autoriser'];

$montant_egaux=$_POST['montant_egaux'];

$montant_different=$_POST['montant_diff'];

$janvier=$_POST['janvier'];

$fevrier=$_POST['fevrier'];

$mars=$_POST['mars'];

$avril=$_POST['avril'];

$mai=$_POST['mai'];

$juin=$_POST['juin'];

$juillet=$_POST['juillet'];

$aoust=$_POST['aoust'];

$septembre=$_POST['septembre'];

$octobre=$_POST['octobre'];

$novembre=$_POST['novembre'];

$decembre=$_POST['decembre'];

$entente_particuliere=$_POST['entente_particuliere'];

$raison_entente=$_POST['raison_entente'];

$number_card=$_POST['number_card'];

$expiration=$_POST['expiration'];



require "config.php";



$connection = mysql_connect($dbhost, $dbusername, $dbpass);

		$SelectedDB = mysql_select_db($dbname);





//Writes the information to the database

$query =("INSERT INTO membres_gym_payments (client_id,montant_total_contrat,premier_versement,solde_restant,visa,mastercard,amex,debit,cash,cheque,nombre_vers_sub,pre_autoriser,montant_egaux,montant_different,janvier,fevrier,mars,avril,mai,juin,juillet,aoust,septembre,octobre,novembre,decembre,entente_particuliere,raison_entente,number_card,expiration) ".

        "VALUES ('$client_id','$montant_total_contrat','$premier_versement','$solde_restant','$visa','$mastercard','$amex','$debit','$cash','$cheque','$nombre_vers_sub','$pre_autoriser','$montant_egaux','$montant_different','$janvier','$fevrier','$mars','$avril','$mai','$juin','$juillet','$aoust','$septembre','$octobre','$novembre','$decembre','$entente_particuliere','$raison_entente','$number_card','$expiration')");

//Writes the photo to the server

$dcdc=mysql_query($query);


if (!$dcdc) {

    // Error

    echo "Sorry, there was an updating  your file $id.";

} else {

    //Writes the photo to the server

    echo "Your file was changed";

	echo "You'll be redirected to Home Page after (2) Seconds";

          echo "<meta http-equiv=Refresh content=2;url=form_interne_paiment.php>";

}

?>






#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
do

mysql_query($query) or die ("SQL: ".$query."\nError: ".mysql_error())
instead of your current query and tell us the error message.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
techker

techker

    Programmer

  • Members
  • PipPipPipPip
  • 136 posts
SQL: INSERT INTO membres_gym_payments (client_id,montant_total_contrat,premier_versement,solde_restant,visa,mastercard,amex,debit,cash,cheque,nombre_vers_sub,pre_autoriser,montant_egaux,montant_different,janvier,fevrier,mars,avril,mai,juin,juillet,aoust,septembre,octobre,novembre,decembre,entente_particuliere,raison_entente,number_card,expiration) VALUES ('6','','','','','','','','','','','','','','','','','','','','','','','','','','','','','') Error: Duplicate entry '0' for key 1

#4
techker

techker

    Programmer

  • Members
  • PipPipPipPip
  • 136 posts
ok so i googled it and it was because it did not set the databse to null and auto increment..lol

thx!!

#5
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
this shows two things. one, your variable values is empty after the first one.
second, an unique key wont allow the insert. check what the index key 1 consist of.

for me, that table layout seems not that worked through.
why not has a "month" field, and set the month as a value? and the same with credit card types. you can always get statistics through good queries.

best way is to insert an numerical value, on months, it's number, for payments, make a table with the different payment types like this:
id, type
1, amex
2, visa
3, mc
4, debit
5, cash
6, cheque


use the strengths of the databases.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall