|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
WML - WML form wont insert record into mysql via php.
Hi there everyone, im kinda having trouble getting my application to store data, my problem is that it seems to connect to mysql but then it says " ("Could not add data to the table"); "
Im using this wml deck Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="aged" title="Aged Charites">
<p align="center">Select charity to donate </p>
<p>
<select>
<option title="Pilgrim Homes" onpick="#pilgrimhomes">Pilgrim Homes</option>
<option title="Guild Care" onpick="#guildcare">Guild Care</option>
<option title="Carers UK" onpick="#carersuk">Carers UK</option>
<br/><br/>
</p>
<p>
<a href="menu.wml#main">Main menu</a>
</p>
</card>
<card id="pilgrimhomes" title="Pilgrim Homes">
<p>We have been looking after needy, elderly Christians since 1807.<br/></p>
<p align="center"><b>Form<b/></p>
<p>
Name: <input name="name" size="15"/>
Adddress: <input name="address" size="15"/>
Credit card no: <input name="ccn" size="15"/>
Expiry date mm/yy: <input name="expirydate" size="15"/>
Security code: <input name="securitycode" size="15"/>
Amount to donate: <input name="amount" size="15"/>
<anchor>
<go method="post" href="agedpillgrimhomes.php">
<postfield name="name" value="$(name)"/>
<postfield name="address" value="$(address)"/>
<postfield name="ccn" value="$(ccn)"/>
<postfield name="expirydate" value="$(expirydate)"/>
<postfield name="securitycode" value="$(securitycode)"/>
<postfield name="amount" value="$(amount)"/>
</go>
Submit
</anchor>
</p>
<p>
<a href="menu.wml#main">Main menu</a>
</p>
</wml>
and this is my php code to store the data but its not working Code:
<?php header('Content-type: text/vnd.wap.wml'); ?>
<?php echo '<?xml version="1.0"?'.'>'; ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">
<?php
#this script stores form entry data as before but will validate for empty fields
# and check for a duplicate record of the book, in either case an error message
# will be displayed in the client
import_request_variables("P", "mypost_");
/* Get the posted book form's values from the request object*/
$name = $mypost_name;
$address = $mypost_address;
$ccn = $mypost_ccn;
$expirydate = $mypost_expirydate;
$securitycode = $mypost_securitycode;
$amount = $mypost_amount;
if (empty($name) || empty($address) || empty($ccn) || empty($expirydate) || empty($securitycode) || empty($amount))
{
echo "Please go back and fill in all the fields";
}
else
{
//db connection - Note how the next few lines have moved away from the book data storage SQL
$connection = @mysql_pconnect("localhost", "admin", "admin") or die("cannot make connection");
/* Set up database and table names */
$db_name = "wml";
$table_name = "agedpillgrimhomes";
//Open db connection
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$query = "SELECT name FROM $table_name WHERE name ='$name'";
$result = mysql_query($query, $connection);
$numrows = mysql_num_rows($result);
if ($numrows == "0")
{
//No match - book is unique
//Create SQL string
$insert = "INSERT INTO $table_name (name,address,ccn,expirydate,securitycode,amount) VALUES ('$name','$address','$ccn','$expirydate','$securitycode','$amount'";
mysql_query($insert) or die ("Could not add data to the table");
echo "Your donation has been successfully recieved";
}
else
{
//The book has been entered on a previous occasion
echo "Your donation was not accepted this time";
exit();
}
}
?>
ive created a database via mysql but does not work cause the record wont insert. Ive made sure the phone simulator is in good order but still no luck. Can anyone help please ![]() Thanks |
|
#2
|
||||
|
||||
|
Hi and welcome to Dev Shed.
Try print_r the $_POST variables at every stage to see that they exist. Also, try echoing out your $insert query. You could also use mysql_error() and error_no for more info...
__________________
Cheers, Jamie # skiFFie | Home of the 'accessibility module' for Drupal # Jamie Burns [me] Accessibility Module [drupal] # guidelines | search | wap resources | not getting help | fold to cure # Any form of employment is strictly prohibited ...... __________________ Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. __________________ |
|
#3
|
|||
|
|||
|
i have problems with inserting my records into database using servlets
|
|
#4
|
|||
|
|||
|
shruthi_cd> Don't hijack someone else's old thread with a separate question. Please find the appropriate forum to post in, create a lucid, relevant post and wait patiently for a response.
__________________
BookMooch.com : Give books away. Get books you want. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > WAP Programming > WML - WML form wont insert record into mysql via php. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|