Jump to content

i think i'm kinda close but am going in circles, i think


sladepowers

Recommended Posts

hope i'm in the right place.

 

Hello,my name is carlton.

i have a html form i created in dreamweaver cs.

i have the accompanying .php script to forward

user details to the server. i fill in the form,

hit the submit button and nothing appears in

the table i created. the testing server has been

successfully configured the database "babiesnmovies"

is recognized by dreamweaver.

PLS tell me what i'm missing.

 

below is a copy of the form and the script.

 

Thank you so much.

 

 

//this is the HTML registration web form i created in dreamweaver//

 

<legend>Parents Contact Information</legend>
      </h3>
      <form id="form1" name="form1" method="PUT" action="babiesnmovies.php">
        <p>
          <label for="babiesnmovies.com/register">Your First Name</label>
          <input type="text" name="yourfirstname" id="babiesnmovies.com/register" /> 
          <label for="babiesnmovies.com/registered">Your Last Name</label>
          <input type="text" name="yourlastname" id="babiesnmovies.com/registered" />
        </p>
        <label for="babiesnmovies.com/yourname">Your Phone Number</label>
        <input type="text" name="yourphonenumber" id="babiesnmovies.com/yourname" />
        <label for="babiesnmovies.com/email">Your E-mail</label>
        <input type="text" name="youremail" id="babiesnmovies.com/email" />
        </p>
    </form>
        <p> </p>
    <h3>
      <legend>Baby's Vitals</legend>
    </h3>
    <form id="form2" name="form2" method="PUT" action="babiesnmovies.php">
      <p>
        <label for="babiesnmovies.com/baby'slast">Baby's First Name</label>
        <input type="text" name="babysfirstname" id="babiesnmovies.com/baby'sfirst" />
        <label for="babiesnmovies.com/babies">Baby's Middle Name</label>
        <input type="text" name="babysmiddlename" id="babiesnmovies.com/babies" />
      </p>
      <p>
        <label for="babyslastname">Baby's Last Name</label>
        <input type="text" name="babyslastname" id="babyslastname" />
      </p>
      <p>
        <label for="babiesnmovies.com/babybday">Baby's Birthdate</label>
        <input type="text" name="babysbirthdate" id="babiesnmovies.com/babybday" />
        <label for="babiesnmovies.com/babyage">Baby's Age</label>
        <input type="text" name="babysage" id="babiesnmovies.com/babyage" />
        
      </p>
      <p>
        <label for="babiesnmovies.com/baby">Baby's Height</label>
        <input type="text" name="babysheight" id="babiesnmovies.com/baby" />
        <label for="babiesnmovies.com/babyweight">Baby's Weight</label>
        <input type="text" name="babysweight" id="babiesnmovies.com/babyweight" />
      </p>
      <p>
        <label for="babiesnmovies.com/babyeyes">Baby's Eye Color</label>
        <input type="text" name="babyseyecolor" id="babiesnmovies.com/babyeyes" />
        <label for="babiesnmovies.com/babyhair">Baby's Hair Color</label>
        <input type="text" name="babyshaircolor" id="babiesnmovies.com/babyhair" />
      </p>
      <p>
        <label for="babiesnmovies.com/babyrace">Baby's Ethnicity</label>
        <input type="text" name="babysethnicity" id="babiesnmovies.com/babyrace" />
      </p>
      <p><input name="formsubmit" type="submit" value="Submit" />
    </form>

 

//this is the babiesnmovies.php script//

 

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_babiesnmovies = "XXX";
$database_babiesnmovies = "XXX";
$username_babiesnmovies = "XXX";
$password_babiesnmovies = "XXX";
$babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR); 


mysql_select_db("db337879506", $con);
	 $sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
	 BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL','$yourfirstname',                  '$yourlastname', '$yourphonenumber', 'youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";



$yourfirstname = $_POST ['YourFirstName'];
$yourlastname = $_POST ['YourLastName'];
$yourphonenumber = $_POST ['YourPhoneNumber'];
$youremailaddress = $_POST ['YourE-mailAddress'];
$babysfirstname = $_POST ['BabysFirstName'];
$babysmiddlename = $_POST ['BabysMiddleName'];
$babyslastname = $_POST ['BabysLastName'];
$babysbirthdate = $_POST ['BabysBirthdate'];
$babysage = $_POST ['BabysAge'];
$babysheight = $_POST ['BabysHeight'];
$babysweight = $_POST ['BabysWeight'];
$babyseyecolor = $_POST ['BabysEyeColor'];
$babyshaircolor = $_POST ['BabysHairColor'];
$babysethicity = $_POST ['Babys Ethnicity'];

?>

 

 

Thank you. :confused: :'(

Link to comment
Share on other sites

WOW, what a really fast response time :o Thank you so much. i made the changes as noted below

filled in the form, submitted it but i still receive none of the data in the database panel in dreamweaver.

 

<?php

# FileName="Connection_php_mysql.htm"

# Type="MYSQL"

# HTTP="true"

$hostname_babiesnmovies = "XXX";

$database_babiesnmovies = "XXX";

$username_babiesnmovies = "XXX";

$password_babiesnmovies = "XXX";

$babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies)

or trigger_error(mysql_error(),E_USER_ERROR);

 

 

mysql_select_db("db337879506", $con);

 

$yourfirstname = $_POST ['YourFirstName'];

$yourlastname = $_POST ['YourLastName'];

$yourphonenumber = $_POST ['YourPhoneNumber'];

$youremailaddress = $_POST ['YourE-mailAddress'];

$babysfirstname = $_POST ['BabysFirstName'];

$babysmiddlename = $_POST ['BabysMiddleName'];

$babyslastname = $_POST ['BabysLastName'];

$babysbirthdate = $_POST ['BabysBirthdate'];

$babysage = $_POST ['BabysAge'];

$babysheight = $_POST ['BabysHeight'];

$babysweight = $_POST ['BabysWeight'];

$babyseyecolor = $_POST ['BabysEyeColor'];

$babyshaircolor = $_POST ['BabysHairColor'];

$babysethicity = $_POST ['Babys Ethnicity'];

 

$sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,

BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL',

'$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',

'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

 

?>

 

Thanks again for the response time...i may finally get somewhere

Link to comment
Share on other sites

hello, made the change to POST  from PUT (silly me), then added the

last line to the script...still nothing in the dw databases panel in the

table "register". pls see below:

 

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_babiesnmovies = "XXX";
$database_babiesnmovies = "XXX";
$username_babiesnmovies = "XXX";
$password_babiesnmovies = "XXX";
$babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) 
or trigger_error(mysql_error(),E_USER_ERROR); 

mysql_select_db("db337879506", $con);

$yourfirstname = $_POST ['YourFirstName'];
$yourlastname = $_POST ['YourLastName'];
$yourphonenumber = $_POST ['YourPhoneNumber'];
$youremailaddress = $_POST ['YourE-mailAddress'];
$babysfirstname = $_POST ['BabysFirstName'];
$babysmiddlename = $_POST ['BabysMiddleName'];
$babyslastname = $_POST ['BabysLastName'];
$babysbirthdate = $_POST ['BabysBirthdate'];
$babysage = $_POST ['BabysAge'];
$babysheight = $_POST ['BabysHeight'];
$babysweight = $_POST ['BabysWeight'];
$babyseyecolor = $_POST ['BabysEyeColor'];
$babyshaircolor = $_POST ['BabysHairColor'];
$babysethicity = $_POST ['Babys Ethnicity'];


$sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL',
'$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

mysql_query($sql, $con) or die (mysql_error());

?>

 

I can say this much...i am much further ahead than i was this morning and your assistance has been the best.

Pls continue to work with me. Thank you.

 

[attachment deleted by admin]

Link to comment
Share on other sites

You should be throwing errors, because your database isn't opened.

 

You use

 

$babiesnmovies = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) or trigger_error(mysql_error(),E_USER_ERROR);

 

but then use

 

mysql_select_db("db337879506", $con);

 

$con isn't defined so you never open the DB.

 

Link to comment
Share on other sites

it worked!!!  ;) this is the exception i got when i hit the submit button:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '', '', '', '', '', '', '', '', '', '', '')' at line 3

 

i kinda understand but then again i don't. but i am closer.

Link to comment
Share on other sites

hello all who have helped me on my way.

i followed the last set of instructions and the script is now as such:

 

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_babiesnmovies = "XXX";
$database_babiesnmovies = "XXX";
$username_babiesnmovies = "XXX";
$password_babiesnmovies = "XXX";
$con = mysql_pconnect($hostname_babiesnmovies, $username_babiesnmovies, $password_babiesnmovies) 
or trigger_error(mysql_error(),E_USER_ERROR); 


mysql_select_db("db337879506", $con);

$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourE-mailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['Babys Ethnicity'];


$sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL',
'$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

mysql_query($sql, $con) or die (mysql_error());

?>

 

i imputed random text in the fields and this is what the exception reads:

 

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dfg')' at line 3"

;)

thank you so much revraz and Pikachu2000

Link to comment
Share on other sites

there is an error in your SQL syntax. take a look to see what your SQL looks like.

 

$sql="INSERT INTO register (id, YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ( 'NULL',
'$yourfirstname','$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

echo "sql: $sql";

Link to comment
Share on other sites

i would like to thank all those that have helped me to get this far:

revraz

Picachu2000

BlueSkyIS

 

can anyone tell me specifically how to access this line in sql?

 

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '', '', '', '', '', '', '', '', '', '', '')' at line 3"

 

i'm going through a hosting

service and use my-phpadmin. is this where i would locate where the error is?

i also access this database via dreamweaver. perhaps i may be able to fix it through there.

 

if there is anyone who can further guide me in how or where to have this issue resolved,

pls post.

 

 

 

Link to comment
Share on other sites

In your form you have the method= attribute specified as 'PUT', however, that isn't a valid method. That's why none of the variables have values. The valid methods are post and get. In this case, since the script that does the processing uses $_POST vars, the proper method for the form is post. You also have 2 separate forms, with one submit button. That isn't going to work, I'm afraid. You should be able to just remove the lines I've commented below to solve that problem.

 

<form id="form1" name="form1" method="PUT" action="babiesnmovies.php"> // <---- CHANGE PUT TO post

. . . [sNIP] . . .

<input type="text" name="youremail" id="babiesnmovies.com/email" />
        </p>
    </form>   // <----- REMOVE THIS
        <p> </p>
    <h3>
      <legend>Baby's Vitals</legend>
    </h3>
    <form id="form2" name="form2" method="PUT" action="babiesnmovies.php">  <---- REMOVE THIS
      <p>
        <label for="babiesnmovies.com/baby'slast">Baby's First Name</label>

 

You should also enclose the whole php script in a conditional that will stop a database insert from happening if the form hasn't been submitted, and validate and sanitize the data from the form before it goes into the query string, but let's at least get it working first.

Link to comment
Share on other sites

i think i need to echo the sql. but i don't know how. i've copied other snippets and put my

info into them and...this is the most basic of exercises in php. php for dummies didn't make it

any clearer for me.

 

but i did remove two of the query:

 

i removed "id" field and the "NULL" from the value it now looks like this:

 

$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourE-mailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['Babys Ethnicity'];


mysql_select_db("db337879506", $con);
	 $sql="INSERT INTO register (YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
	 BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ('$yourfirstname', 
	 '$yourlastname', '$yourphonenumber', $youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname', 
	 '$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

	  mysql_query($sql, $con) or die (mysql_error());

?>

 

how do i echo this

Link to comment
Share on other sites

While in development, your queries should be executed in such a manner that if there is an error, it not only echos the error, but also the query string. So to do that, you'd change:

 mysql_query($sql, $con) or die (mysql_error());

 

To:

 mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');

 

You should also be developing with display_errors = On, and error_reporting = E_ALL | E_STRICT. You can make those changes in your php.ini file, assuming you're developing and testing on a local machine. If you don't have access to make those changes, you can add the following to your scripts

ini_set('display_errors', 1);
error_reporting(-1);

Link to comment
Share on other sites

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.