PDA

View Full Version : Help with this error?


Jeffrey06
07-10-2008, 06:35 AM
After 5 hours of finally getting my database configuration correct. On my add.php page i'm getting this error:

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/*******/public_html/vendordatabase/add.php on line 81

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/******/public_html/vendordatabase/add.php on line 83

...

I'm certain it's a pretty simple error. But, i'm not that experienced at coding yet. I'm learning as much as I can..

Here is my code:


<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 products (productName, price, `description`, inventory, vendorID, categoryID, image, onSale) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['productName'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['inventory'], "text"),
GetSQLValueString($_POST['vendorID'], "int"),
GetSQLValueString($_POST['categoryID'], "int"),
GetSQLValueString($_POST['image'], "text"),
GetSQLValueString($_POST['onSale'], "int"));
mysql_select_db($database_connDiesel, $connDiesel);
$Result1 = mysql_query($insertSQL, $connDiesel) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO category (categoryID, categoryName) VALUES (%s, %s)",
GetSQLValueString($_POST['categoryID'], "int"),
GetSQLValueString($_POST['categoryName'], "text"));
mysql_select_db($database_connDiesel, $connDiesel);
$Result1 = mysql_query($insertSQL, $connDiesel) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form3")) {
$insertSQL = sprintf("INSERT INTO vendors (vendorName, vendorStreet, vendorCity, vendorState, vendorZip, vendorPhone) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['vendorName'], "text"),
GetSQLValueString($_POST['vendorStreet'], "text"),
GetSQLValueString($_POST['vendorCity'], "text"),
GetSQLValueString($_POST['vendorState'], "text"),
GetSQLValueString($_POST['vendorZip'], "text"),
GetSQLValueString($_POST['vendorPhone'], "text"));
mysql_select_db($database_connDiesel, $connDiesel);
$Result1 = mysql_query($insertSQL, $connDiesel) or die(mysql_error());
}
mysql_select_db($database_connDiesel, $connDiesel);
$query_rsVendors = "SELECT * FROM vendors ORDER BY vendorName DESC";
$rsVendors = mysql_query($query_rsVendors, $connDiesel) or die(mysql_error());
$row_rsVendors = mysql_fetch_assoc($rsVendors);
$totalRows_rsVendors = mysql_num_rows($rsVendors);
mysql_select_db($database_connDiesel, $connDiesel);
$query_rsCategories = "SELECT * FROM category ORDER BY categoryName ASC";
$rsCategories = mysql_query($query_rsCategories, $connDiesel) or die(mysql_error());
$row_rsCategories = mysql_fetch_assoc($rsCategories);
$totalRows_rsCategories = mysql_num_rows($rsCategories);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DieselHaulin.com Online Store</title>
<style type="text/css">
<!--
.style1 {
font-size: 16px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
#apDiv2 {
position:absolute;
left:375px;
top:21px;
width:511px;
height:91px;
z-index:2;
}
-->
</style>
<style type="text/css">
<!--
body {
background-color: #999999;
}
#apDiv1 {
position:absolute;
left:14px;
top:143px;
width:130px;
height:31px;
z-index:3;
}
#apDiv3 {
position:absolute;
left:14px;
top:123px;
width:420px;
height:56px;
z-index:3;
}
#apDiv4 {
position:absolute;
left:11px;
top:226px;
width:167px;
height:395px;
z-index:4;
border: thin solid #666666;
}
#apDiv5 {
position:absolute;
left:804px;
top:150px;
width:71px;
height:47px;
z-index:5;
}
#apDiv6 {
position:absolute;
left:12px;
top:196px;
width:899px;
height:17px;
z-index:6;
background-color: #666666;
}
#apDiv7 {
position:absolute;
left:220px;
top:242px;
width:651px;
height:269px;
z-index:7;
}
.style10 {font-size: 16px}
.style11 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 24px;
}
#apDiv8 {
position:absolute;
left:14px;
top:635px;
width:120px;
height:29px;
z-index:8;
}
#apDiv9 {
position:absolute;
left:14px;
top:150px;
width:613px;
height:36px;
z-index:9;
}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<style type="text/css">
<!--
.style13 {
font-size: 18px
}
#apDiv10 {
position:absolute;
left:222px;
top:584px;
width:647px;
height:41px;
z-index:10;
}
#apDiv11 {
position:absolute;
left:198px;
top:228px;
width:799px;
height:33px;
z-index:11;
}
#apDiv12 {
position:absolute;
left:199px;
top:276px;
width:809px;
height:215px;
z-index:12;
}
.style14 {font-size: 18}
.style15 {font-size: 14px}
#apDiv13 {
position:absolute;
left:197px;
top:277px;
width:862px;
height:489px;
z-index:12;
}
-->
</style>
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="style11" id="apDiv4">
<div id="sidebar1">
<div class="related">
<h2>Store Admin</h2>
<ul>
<li><span class="style13"><span class="style14"><span class="style15"><a href="admin.php">Admin Home</a></span></span></span></li>
<li class="style15"><a href="add.php">Add Records</a></li>
<li class="style15"><a href="delete.php">Delete Records</a></li>
<li class="style15"><a href="edit.php">Update Records</a></li>
<li><span class="style15"><a href="#">Log Out</a></span></li>
</ul>
</div>
<div class="natEx">
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<!-- end #sidebar1 -->
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<div id="apDiv5">
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','108','height ','46','src','accountbut','quality','high','plugin spage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgco lor','#999999','movie','accountbut' ); //end AC code
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="108" height="46">
<param name="movie" value="accountbut.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#999999" />
<embed src="accountbut.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="108" height="46" bgcolor="#999999"></embed>
</object>
</noscript>
</div>
<div id="apDiv6"></div>
<div id="apDiv9">
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','108','height ','46','src','button1','quality','high','pluginspa ge','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgco lor','#999999','movie','button1' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="108" height="46">
<param name="movie" value="button1.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#999999" />
<embed src="button1.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="108" height="46" bgcolor="#999999"></embed>
</object>
</noscript>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','108','height ','46','src','button2','quality','high','pluginspa ge','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgco lor','#999999','movie','button2' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="108" height="46">
<param name="movie" value="button2.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#999999" />
<embed src="button2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="108" height="46" bgcolor="#999999"></embed>
</object>
</noscript></div>
<div id="apDiv11">ADD DATABASE RECORDS</div>
<div id="apDiv13">
<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li class="TabbedPanelsTab" tabindex="0">Add Product</li>
<li class="TabbedPanelsTab" tabindex="0">Add Category</li>
<li class="TabbedPanelsTab" tabindex="0">Add Vendor</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div class="TabbedPanelsContent">
<p>&nbsp;</p>

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Product Name:</td>
<td><textarea name="productName" cols="50" rows="5"></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Price:</td>
<td><input type="text" name="price" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Description:</td>
<td><input type="text" name="description" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Inventory Status:</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="inventory" value="In Stock" />
In Stock</td>
</tr>
<tr>
<td><input type="radio" name="inventory" value="Back Order" />
Back Order</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Vendor:</td>
<td><select name="vendorID">
<?php
do {
?>
<option value="<?php echo $row_rsVendors['vendorID']?>" ><?php echo $row_rsVendors['vendorName']?></option>
<?php
} while ($row_rsVendors = mysql_fetch_assoc($rsVendors));
?>
</select>
</td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Category:</td>
<td><select name="categoryID">
<?php
do {
?>
<option value="<?php echo $row_rsCategories['categoryID']?>" ><?php echo $row_rsCategories['categoryName']?></option>
<?php
} while ($row_rsCategories = mysql_fetch_assoc($rsCategories));
?>
</select>
</td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Image File:</td>
<td><input type="text" name="image" value="none.gif" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">On Sale:</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="onSale" value="1" />
Yes</td>
</tr>
<tr>
<td><input type="radio" name="onSale" value="0" />
No</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</div>
<div class="TabbedPanelsContent">
<p>&nbsp;</p>

<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Category:</td>
<td><input type="text" name="categoryID" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">CategoryName:</td>
<td><select name="categoryName">
<?php
do {
?>
<option value="<?php echo $row_rsCategories['categoryID']?>" ><?php echo $row_rsCategories['categoryName']?></option>
<?php
} while ($row_rsCategories = mysql_fetch_assoc($rsCategories));
?>
</select>
</td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<div class="TabbedPanelsContent">
<p>&nbsp;</p>

<form action="<?php echo $editFormAction; ?>" method="post" name="form3" id="form3">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Name:</td>
<td><input type="text" name="vendorName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Street:</td>
<td><input type="text" name="vendorStreet" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">City:</td>
<td><input type="text" name="vendorCity" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">State:</td>
<td><input type="text" name="vendorState" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Zip:</td>
<td><input type="text" name="vendorZip" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Phone:</td>
<td><input type="text" name="vendorPhone" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form3" />
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</div>
</div>
</div>
<span class="style10"><img src="completelogo.gif" alt="" width="351" height="119" /></span>
<div class="style1" id="apDiv2">DieselHaulin.com Online Forums Store</div>
<span class="style10"></span>
<script type="text/javascript">
<!--
var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
//-->
</script>
</body>
</html>
<?php
mysql_free_result($rsVendors);
mysql_free_result($rsCategories);
?>

davidj
07-10-2008, 06:48 AM
sorry mate

i just noticed that it was DW code

ill leave this for someone else to help you

Jeffrey06
07-10-2008, 06:58 AM
sorry mate

i just noticed that it was DW code

ill leave this for someone else to help you

I wish I could hand code it! :mrgreen:

Hopefully somebody can chime in with some help..:)

davidj
07-10-2008, 07:04 AM
if you really want to learn to code and have time to invest in yourself then post a reply back

i can help

edbr
07-10-2008, 07:17 AM
dw code is over complicated but what are the 2 lines 81 and 83.
Have to echo Davids answer if you have time or can make it try his vids, they will help you

Jeffrey06
07-10-2008, 10:27 PM
Thanks guys. I just started the page over again.

As far as learning. I've studied though David's videos and they have been alot of help. I'm currently in college for computer science major. So, I have to learn coding soon, along with I want to get a jump start before diving in head first...:grin:

davidj
07-10-2008, 11:03 PM
if your going to get anywhere with this professionally then you need to dive in from the highest board.

if you dont do this now its going to be harder later on