Jump to content

demented_gurl

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

demented_gurl's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hye. i'm trying to compare 2strings, 1string is passed from the database, and the other string is passed from a textfield in a form. below is the code that i have tried, but the page shows an error concerning " while($Row= mysql_fetch_row($result)) "..please help. current_project_title - is the column name of the previous projects stored. project_name - the project name passed from textfield. <?php $current_project_title = $_Get["current_project_title"]; $query = "SELECT * FROM project"; $result = mysql_query($query); $similar = 0; while($Row= mysql_fetch_row($result)) { $project_name = $Row["project_name"]; if (strcmp($current_project_title,$project_name) > 90%) similar = 1; echo ("$project_name",$year); } if($similar > 0) {no register} else {register}; ?>
  2. <?php session_start(); $CoID=$_SESSION['CoID']; ?> <?php require_once('Connections/dbconnection.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO company (ContactName, CoName, CoID, CoAdd, NumOffice, NumHP, NumFax, Email, ContactPreferences) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['ContactName'], "text"), GetSQLValueString($_POST['CoName'], "text"), GetSQLValueString($_POST['CoID'], "int"), GetSQLValueString($_POST['CoAdd'], "text"), GetSQLValueString($_POST['NumOffice'], "text"), GetSQLValueString($_POST['NumHP'], "text"), GetSQLValueString($_POST['NumFax'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['ContactPreferences'], "text")); mysql_select_db($database_dbconnection, $dbconnection); $Result1 = mysql_query($insertSQL, $dbconnection) or die(mysql_error()); $insertGoTo = "insertEventDetails.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">ContactName:</td> <td><input type="text" name="ContactName" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">CoName:</td> <td><input type="text" name="CoName" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">CoAdd:</td> <td><input type="text" name="CoAdd" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">NumOffice:</td> <td><input type="text" name="NumOffice" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">NumHP:</td> <td><input type="text" name="NumHP" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">NumFax:</td> <td><input type="text" name="NumFax" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Email:</td> <td><input type="text" name="Email" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">ContactPreferences:</td> <td><input type="text" name="ContactPreferences" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="CoID" value=""> <input type="hidden" name="MM_insert" value="form1"> </form> <p> </p> </body> </html> the CoID is a hidden file..and i would like to pass the value that the Mysql has assigned to the next page to be displayed..
  3. thanks..can i pls know how to do that?..I'm sorry..am new to this..
  4. Hye. I'm new to PHP and I don't know much about the language. I have a form where guests are required to enter their company details (Co name, address, telephone number, etc). and these info will be stored in MySQL database, and the database will generate a unique CoID (using auto-increment in MySQL). My question is, how do I display back the generated CoID to the guest?.. I've tried using session and passing through url, but the CoID won't display because the value of the CoID is not entered in the form. NEED HELP. Thanks in advance.
×
×
  • 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.