gglgokop1704
Programmer
I used this code after debuging to insert data in a table but the data from the form is not inserted. Please any idea why:
<?php
if($_REQUEST['criteriaid'] && $_REQUEST['domainid'] && $_REQUEST['criterianame'] && $_REQUEST['upperlimit'] && $_REQUEST['lowerlimit'] && $_REQUEST['range'] && $_REQUEST['unit'])// Check to see if All of the Fields were Filled Out
{
pg_connect("host=138.250.104.227 dbname=rftDatabase user=globus password=globususer); // Connect to the Database
$query = sprintf("INSERT INTO "Criteria_Parameters" VALUES ('%s','%s','%s' ,'%s','%s','%s','%s')",$_REQUEST['criteriaid'], $_REQUEST['domainid'], $_REQUEST['criterianame'],
$_REQUEST['upperlimit'], $_REQUEST['lowerlimit'], $_REQUEST['range'], $_REQUEST['unit']); // Form the Query
/* Quick Lesson on Sprintf:
* Sprintf Will take a string and format it. In this case I use %s which means that the Next parameter will be A string, and It
* Should be put into wherever the %s is. The parameters will fill the %s's respectively
*/
echo $query;
// Uncomment the previous line to see what $query Contains. Everything that follows is just some simple error checking.
$query = pg_query($query);
if($query)
echo "You have successfully added a record to the database!";
else
echo "Some Error Occured! ".pg_last_error();
}
else{ // If we dont have all of the fields, show the form
?>
<form METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>">
Criteria ID: <input type="text" name="criteriaid" />
Domain ID: <input type="text" name="domainid" />
Criteria Name: <input type="text" name="criterianame" />
Upper Limit: <input type="text" name="upperlimit" />
Lower Limit: <input type="text" name="lowerlimit" />
Range: <input type="text" name="range" />
Unit: <input type="text" name="unit" />
<input type="submit" />
</form>
<?php
}
globus user has privilege to create database but does not have priviledge to create users. globus is not a superuser and cannot update catalogs. Could that be the reason why the data is not inserting.
Kind regards
Gokop
<?php
if($_REQUEST['criteriaid'] && $_REQUEST['domainid'] && $_REQUEST['criterianame'] && $_REQUEST['upperlimit'] && $_REQUEST['lowerlimit'] && $_REQUEST['range'] && $_REQUEST['unit'])// Check to see if All of the Fields were Filled Out
{
pg_connect("host=138.250.104.227 dbname=rftDatabase user=globus password=globususer); // Connect to the Database
$query = sprintf("INSERT INTO "Criteria_Parameters" VALUES ('%s','%s','%s' ,'%s','%s','%s','%s')",$_REQUEST['criteriaid'], $_REQUEST['domainid'], $_REQUEST['criterianame'],
$_REQUEST['upperlimit'], $_REQUEST['lowerlimit'], $_REQUEST['range'], $_REQUEST['unit']); // Form the Query
/* Quick Lesson on Sprintf:
* Sprintf Will take a string and format it. In this case I use %s which means that the Next parameter will be A string, and It
* Should be put into wherever the %s is. The parameters will fill the %s's respectively
*/
echo $query;
// Uncomment the previous line to see what $query Contains. Everything that follows is just some simple error checking.
$query = pg_query($query);
if($query)
echo "You have successfully added a record to the database!";
else
echo "Some Error Occured! ".pg_last_error();
}
else{ // If we dont have all of the fields, show the form
?>
<form METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>">
Criteria ID: <input type="text" name="criteriaid" />
Domain ID: <input type="text" name="domainid" />
Criteria Name: <input type="text" name="criterianame" />
Upper Limit: <input type="text" name="upperlimit" />
Lower Limit: <input type="text" name="lowerlimit" />
Range: <input type="text" name="range" />
Unit: <input type="text" name="unit" />
<input type="submit" />
</form>
<?php
}
globus user has privilege to create database but does not have priviledge to create users. globus is not a superuser and cannot update catalogs. Could that be the reason why the data is not inserting.
Kind regards
Gokop