Can anyone see what the problem is?

  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

I am using this code to submit data to MySQL
Code: [ Select ]
<?php
$conn = dbConnect();
dbSelect();
if(isset($_POST['fname'])){
 
$dob1 = $_POST['dob1']; // day
$dob2 = $_POST['dob2']; // month   
$dob3 = $_POST['dob3']; // year
 
$dob = $dob3."-".$dob2."-".$dob1;
 
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $email = $_POST['email'];
    $sex = $_POST['sex'];
    $country = $_POST['country'];
    $town = $_POST['town'];
    $user = $_POST['user'];
    $pass = $_POST['1pass'];
    $hint = $_POST['hint'];
$query = "
        INSERT
        INTO
        tb_members
        (f_user, f_pass, f_hint, f_fname, f_flname, f_dob, f_country, f_town, f_email, f_sex)
        VALUES
        (username, password3, passwordhint, bob, smith, 1989-01-05, england, huddersfield, bobsmith@dd.com, male)
        ";
         print $query;
       
       
       
    mysql_query($query) or die (mysql($error));
;
}
?>
  1. <?php
  2. $conn = dbConnect();
  3. dbSelect();
  4. if(isset($_POST['fname'])){
  5.  
  6. $dob1 = $_POST['dob1']; // day
  7. $dob2 = $_POST['dob2']; // month   
  8. $dob3 = $_POST['dob3']; // year
  9.  
  10. $dob = $dob3."-".$dob2."-".$dob1;
  11.  
  12.     $fname = $_POST['fname'];
  13.     $lname = $_POST['lname'];
  14.     $email = $_POST['email'];
  15.     $sex = $_POST['sex'];
  16.     $country = $_POST['country'];
  17.     $town = $_POST['town'];
  18.     $user = $_POST['user'];
  19.     $pass = $_POST['1pass'];
  20.     $hint = $_POST['hint'];
  21. $query = "
  22.         INSERT
  23.         INTO
  24.         tb_members
  25.         (f_user, f_pass, f_hint, f_fname, f_flname, f_dob, f_country, f_town, f_email, f_sex)
  26.         VALUES
  27.         (username, password3, passwordhint, bob, smith, 1989-01-05, england, huddersfield, bobsmith@dd.com, male)
  28.         ";
  29.          print $query;
  30.        
  31.        
  32.        
  33.     mysql_query($query) or die (mysql($error));
  34. ;
  35. }
  36. ?>

I am hard coding in the results for testing but even so it should submit it to MySQL what it comes up with is an error complaining about this line
Code: [ Select ]
mysql_query($query) or die (mysql($error));
now ive used the same code later on and it works fine so can anyone see the issue here?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8398
  • Loc: USA

Post 3+ Months Ago

tastysite wrote:
I am using this code to submit data to MySQL
Code: [ Select ]
...[/SNIP\]...

I am hard coding in the results for testing but even so it should submit it to MySQL what it comes up with is an error complaining about this line
Code: [ Select ]
mysql_query($query) or die (mysql($error));
now ive used the same code later on and it works fine so can anyone see the issue here?

What is the actual error? You also have a lone semicolon at the end... doubt that it's the one causing problems but you don't need it there.
  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

Good point about the ; had not noticed!
The error is:- Warning: Wrong parameter count for mysql()
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8398
  • Loc: USA

Post 3+ Months Ago

Ahh... why did I not notice this earlier? :lol: Obvious errors are ones that are noticed last haha

That's
Code: [ Select ]
mysql_error();

not
Code: [ Select ]
mysql($error);


There is no actual function mysql(); but there is a MySQL Book.
  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

no sorry that's not working now its complaining about Parse error: syntax error, unexpected T_STRING
  • tastysite
  • Proficient
  • Proficient
  • User avatar
  • Posts: 349
  • Loc: Brighouse, West Yorkshire, England

Post 3+ Months Ago

Sorry my bad :roll: its working now thankyou! :mrgreen:
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8398
  • Loc: USA

Post 3+ Months Ago

tastysite wrote:
Sorry my bad :roll: its working now thankyou! :mrgreen:

Good :D Glad you got it figured out

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 74 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.