Avatar billede elohite Nybegynder
23. marts 2005 - 11:43 Der er 2 kommentarer

PHP MYSQL fejl:

JEg har en side der ser såden ud:

<?php require_once('../inc/authCheck.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 sortingreportline (srId, productNumber, productName, format, amount, location, productType) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                      GetSQLValueString($_POST['srId'], "int"),
                      GetSQLValueString($_POST['productNumber'], "text"),
                      GetSQLValueString($_POST['productName'], "text"),
                      GetSQLValueString($_POST['format'], "int"),
                      GetSQLValueString($_POST['amount'], "int"),
                      GetSQLValueString($_POST['location'], "text"),
                      GetSQLValueString($_POST['productType'], "text"));

  mysql_select_db($database_mysqlCon, $mysqlCon);
  $Result1 = mysql_query($insertSQL, $mysqlCon) or die(mysql_error());
}
?>
<?php require_once('../Connections/mysqlCon.php'); ?>
<?php
mysql_select_db($database_mysqlCon, $mysqlCon);
$query_format = "SELECT formatId, text FROM format";
$format = mysql_query($query_format, $mysqlCon) or die(mysql_error());
$row_format = mysql_fetch_assoc($format);
$totalRows_format = mysql_num_rows($format);
?>

<html><!-- InstanceBegin template="/Templates/newReport.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->



<!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/site.css" rel="stylesheet" type="text/css">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body bgcolor="#FFFFFF">
<table width="100%"  border="0" cellspacing="0" cellpadding="0" height="100%">
  <tr align="left" valign="top">
    <td width="700"></td>
    <td width="700">
        <table width="100%" height="450" >
  <tr align="left" valign="top">
    <td  height="70" class="mainTable"><img src="../images/logo.gif" width="300" height="50"></td>
  </tr>
  <tr>
    <td class="tableHeight">
        <table width="100%" height="450">
  <tr>
    <td width="100" valign="top" class="mainTable"><p>
      <?php
      $thisUserName= $_SESSION['MM_userFullName'];
      echo $thisUserName;
      ?><br><?php echo date('d, m, Y'); ?></p>
      <p><a href="reportNew.php">Ny rapport</a></p>
      <p><a href="reportList.php">Find rapport</a></p>
      <p>Statestik</p>
      <p>Log</p>
      <p>Bruger</p>
      <p>&nbsp;</p>
      <p> <a href="../logout.php">- log ud - </a></p></td>
    <td valign="top"><!-- InstanceBeginEditable name="main" -->
    <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
      <table align="center">
        <tr valign="baseline" class="srTable">
          <td nowrap align="right">Varenummer:</td>
          <td><input type="text" name="productNumber" value="" size="32"></td>
        </tr>
        <tr valign="baseline" class="srTable">
          <td nowrap align="right">Varenavn:</td>
          <td><input type="text" name="productName" value="" size="32"></td>
        </tr>
        <tr valign="baseline" class="srTable">
          <td nowrap align="right">Format:</td>
          <td><select name="format">
              <?php
do { 
?>
              <option value="<?php echo $row_format['formatId']?>" ><?php echo $row_format['text']?></option>
              <?php
} while ($row_format = mysql_fetch_assoc($format));
?>
            </select>
          </td>
        <tr>
        <tr valign="baseline" class="srTable">
          <td nowrap align="right">Antal:</td>
          <td><input type="text" name="amount" value="" size="32"></td>
        </tr>
        <tr valign="baseline" class="srTable">
          <td nowrap align="right">Lokation:</td>
          <td><input type="text" name="location" value="" size="32"></td>
        </tr>
        <tr valign="baseline" class="srTable">
          <td nowrap align="right">ProductType:</td>
          <td><select name="productType">
              <option value="Standard" <?php if (!(strcmp("Standard", ""))) {echo "SELECTED";} ?>>Standard</option>
              <option value="Variant" <?php if (!(strcmp("Variant", ""))) {echo "SELECTED";} ?>>Variant</option>
              <option value="Svind" <?php if (!(strcmp("Svind", ""))) {echo "SELECTED";} ?>>Svind</option>
              <option value="" >item1</option>
            </select>
          </td>
        </tr>
        <tr valign="baseline" class="srTable">
          <td nowrap align="right">&nbsp;</td>
          <td><input type="submit" value="Tilf&oslash;je"></td>
        </tr>
      </table>
      <input type="hidden" name="srId" value="<?php echo $_GET['srId']; ?>">
      <input type="hidden" name="MM_insert" value="form1">
    </form>
    <p>&nbsp;</p>
    <!-- InstanceEndEditable --></td>
    <td width="100" valign="top" class="mainTable">
      <p>&nbsp;</p>
      <!-- InstanceBeginRepeat name="RepeatRegion1" --><!-- InstanceBeginRepeatEntry --><p><a href="reportAddLine.php">Tilf&oslash;je produktion</a></p>
      <p>Print Raport</p>
      <p>Slet Raport </p>
      <!-- InstanceEndRepeatEntry --><!-- InstanceEndRepeat --></p>
    </td>
  </tr>
</table>

    </td>
  </tr>
</table>

    </td>
    <td width="700"></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($format);


?>
**********************************************************

og får følgende fejl:
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/httpd/vhosts/ptsr.dk/httpdocs/report/reportAddLine.php on line 43

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/httpd/vhosts/ptsr.dk/httpdocs/report/reportAddLine.php on line 44
Avatar billede rednex Nybegynder
23. marts 2005 - 11:48 #1
Du skal nok lige lave en mysql_connect() inden du prøver at arbejde med DB'en.
Avatar billede barklund Nybegynder
23. marts 2005 - 11:51 #2
Og dermed definere $database_mysqlCon et sted :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester