Jump to content

Willo009

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Willo009's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hope this is what you asked for Keith, what i did i cleared the tables of all data. And then registered again so the id=1 // WA Application Builder Insert if (isset($_POST["Insert_x"])) // Trigger { $WA_connection = $petsCon; $WA_table = "petdata"; $WA_sessionName = "WADA_Insert_petdata"; $WA_redirectURL = "petdataAdmin_Results.php"; if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):""; $WA_keepQueryString = true; $WA_indexField = "CustomerID"; $WA_fieldNamesStr = "CustomerID|Type|Breed|Age|Colour|Price|SalesPoint|Description|Image1|Image2|VideoClip"; $WA_fieldValuesStr = "".$_SESSION['id'] ."" . "|" . "".((isset($_POST["Type"]))?$_POST["Type"]:"") ."" . "|" . "".((isset($_POST["Breed"]))?$_POST["Breed"]:"") ."" . "|" . "".((isset($_POST["Age"]))?$_POST["Age"]:"") ."" . "|" . "".((isset($_POST["Colour"]))?$_POST["Colour"]:"") ."" . "|" . "".((isset($_POST["Price"]))?$_POST["Price"]:"") ."" . "|" . "".((isset($_POST["SalesPoint"]))?$_POST["SalesPoint"]:"") ."" . "|" . "".((isset($_POST["Description"]))?$_POST["Description"]:"") ."" . "|" . "".((isset($_POST["Image1"]))?$_POST["Image1"]:"") ."" . "|" . "".((isset($_POST["Image2"]))?$_POST["Image2"]:"") ."" . "|" . "".((isset($_POST["VideoClip"]))?$_POST["VideoClip"]:"") .""; $WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''"; $WA_fieldNames = explode("|", $WA_fieldNamesStr); $WA_fieldValues = explode("|", $WA_fieldValuesStr); $WA_columns = explode("|", $WA_columnTypesStr); $WA_connectionDB = $database_petsCon; mysql_select_db($WA_connectionDB, $WA_connection); if (!session_id()) session_start(); $insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1); $WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")"; $MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error()); $_SESSION[$WA_sessionName] = mysql_insert_id(); if ($WA_redirectURL != "") { if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) { $WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"]; } header("Location: ".$WA_redirectURL); } } ?>
  2. I have set-up a new Primary key as PetID and set both PetID & CustomerID as shown but im getting this error Column 'CustomerID' cannot be null
  3. Keith Thankyou so much for your help.
  4. Thankyou hope i got it right. Its a pet classifieds website im trying to get up and running, and trying to create a database that will allow a user to insert as many Ads as they wish. I have followed tutorials but its still not running right and im lost. Thanks for your help Keith [attachment deleted by admin]
  5. Hi Keith Thanks for your help with this, many sleepless nights trying i have had. Its my 1st time using a Database so i am newer than new to all this. As will show here lol, could you tell me how to copy and paste all this info as i do not know where i would find it. Thanks
  6. I have a problem with Foriegn Keys, ive been trying to work it out now for over a week. Ive watched Tutorials after Tutorials, copied what they have said but its not working. And its only a simple Database with 2 Tables which require a FK join. I have 2 tables as shown below: CustomerData (parent table) ID Name Address Email PhoneNumber MobileNumber Country City Password PetData (child table) CustomerID --foreign key linked to ID form parent table Type Breed Age Colour Price SalesPoint Description Image1 Image2 But i just cannot get it to work i keep getting this error: Cannot add or update a child row: a foreign key constraint fails (`petseen`.`petdata`, CONSTRAINT `petdata_ibfk_1` FOREIGN KEY (`CustomerID`) REFERENCES `customerdata` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE) I need the customer to be able to upload as many pets as they wish. any help would be great and many thanks.
  7. Hi Rifts Thanks for your help on this, im very new to Php. Im unsure how too set the value to a Variable? could you show me an example. I have posted all the Php on my page below thanks <?php require_once('Connections/petsCon.php'); ?> <?php //WA Database Search Include require_once("WADbSearch/HelperPHP.php"); ?> <?php //WA Database Search (Copyright 2005, WebAssist.com) //Recordset: ResultsRS; //Searchpage: Index.php; //Form: form1; $WADbSearch1_DefaultWhere = ""; if (!session_id()) session_start(); if ((isset($_POST["WADbSearch1"])) && ($_POST["WADbSearch1"] != "")) { $WADbSearch1 = new FilterDef; $WADbSearch1->initializeQueryBuilder("MYSQL","1"); //keyword array declarations $KeyArr0 = array("breed"); $KeyArr1 = array("price"); $KeyArr2 = array("city"); //comparison list additions $WADbSearch1->addComparisonFromList("type","TypeSearch","AND","=",0); $WADbSearch1->keywordComparison($KeyArr0,"".((isset($_POST["breedSearch"]))?$_POST["breedSearch"]:"") ."","AND","Includes",",%20","%20","%22","%22",0); $WADbSearch1->keywordComparison($KeyArr1,"".((isset($_POST["priceSearch"]))?$_POST["priceSearch"]:"") ."","AND","Includes",",%20","%20","%22","%22",0); $WADbSearch1->addComparisonFromList("country","countrySearch","AND","=",0); $WADbSearch1->keywordComparison($KeyArr2,"".((isset($_POST["citySearch"]))?$_POST["citySearch"]:"") ."","AND","Includes",",%20","%20","%22","%22",0); //save the query in a session variable if (1 == 1) { $_SESSION["WADbSearch1_ResultsPet"]=$WADbSearch1->whereClause; } } else { $WADbSearch1 = new FilterDef; $WADbSearch1->initializeQueryBuilder("MYSQL","1"); //get the filter definition from a session variable if (1 == 1) { if (isset($_SESSION["WADbSearch1_ResultsPet"]) && $_SESSION["WADbSearch1_ResultsPet"] != "") { $WADbSearch1->whereClause = $_SESSION["WADbSearch1_ResultsPet"]; } else { $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere; } } else { $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere; } } $WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause); $WADbSearch1whereClause = ''; ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } $maxRows_ResultsRS = 10; $pageNum_ResultsRS = 0; if (isset($_GET['pageNum_ResultsRS'])) { $pageNum_ResultsRS = $_GET['pageNum_ResultsRS']; } $startRow_ResultsRS = $pageNum_ResultsRS * $maxRows_ResultsRS; $colname_ResultsRS = "-1"; if (isset($_GET['id'])) { $colname_ResultsRS = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } mysql_select_db($database_petsCon, $petsCon); $query_ResultsRS = sprintf("SELECT * FROM petdata INNER JOIN customerdata ON (petdata.id = customerdata.id) WHERE id = %s", GetSQLValueString($colname_ResultsRS, "int")); setQueryBuilderSource($query_ResultsRS,$WADbSearch1,false); $query_limit_ResultsRS = sprintf("%s LIMIT %d, %d", $query_ResultsRS, $startRow_ResultsRS, $maxRows_ResultsRS); $ResultsRS = mysql_query($query_limit_ResultsRS, $petsCon) or die(mysql_error()); $row_ResultsRS = mysql_fetch_assoc($ResultsRS); if (isset($_GET['totalRows_ResultsRS'])) { $totalRows_ResultsRS = $_GET['totalRows_ResultsRS']; } else { $all_ResultsRS = mysql_query($query_ResultsRS); $totalRows_ResultsRS = mysql_num_rows($all_ResultsRS); } $totalPages_ResultsRS = ceil($totalRows_ResultsRS/$maxRows_ResultsRS)-1; ?>
  8. Hi I have a problem i need some help with, when passing values from my Results page to my Details page through a URL is the Querystring different because i have INNER JOINED 2 tables? This is my Querystring <a href="DetailsPet.php?id=<?php echo $row_ResultsRS['id']; ?>">Details</a></td> i have 2 tables (petdata and customerdata) and there INNER JOINED using the 'id' But its not passing on the values, and just shows the 1st results in database all the time. Im only just learning Php, but would i be right in thinking it to do with the 'id' as this is what joins the 2 tables. Do i have to state which 'id' to use? if so how do i do it? Thanks willo
  9. Thanks Guys for offers off help, this is a great forum. I decided to re-do the pages that were causing me problems, it was a late night but there running just fine now. I have a question though, when passing values from my Results page to my Details page through a URL is the Querystring different because i have INNER JOINED 2 tables? This is my Querystring <a href="DetailsPet.php?id=<?php echo $row_ResultsRS['id']; ?>">Details</a></td> But its not passing on the values, and just shows the 1st results in database all the time. Im only just learning Php, but would i be right in thinking it to do with the 'id' as this is what joins the 2 tables. Do i have to state which 'id' to use? if so how do i do it?
  10. This is the info below, thanks for your help <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } mysql_select_db($database_petsCon, $petsCon); $query_RSsearch = "SELECT * FROM petdata"; $RSsearch = mysql_query($query_RSsearch, $petsCon) or die(mysql_error()); $row_RSsearch = mysql_fetch_assoc($RSsearch); $totalRows_RSsearch = mysql_num_rows($RSsearch); $query_RSsearch = "SELECT * FROM petdata"; $RSsearch = mysql_query($query_RSsearch, $petsCon) or die(mysql_error()); $row_RSsearch = mysql_fetch_assoc($RSsearch); $totalRows_RSsearch = mysql_num_rows($RSsearch); ?>
  11. This is the problem? AND type='Dog' AND country='England' LIMIT 0, 10 its just within the code of my Index page i cannot see this, and how would i go about fixing it? Thanks for your speedy reply on this.
  12. Hi Guys I hope its ok to post here with some problems im having. This is my 1st time with trying to use php, and my 1st time attempting to create a website. Im using some extensions from Webassist, and although they can cut down the time it takes to code php. There also not as stated on there website, and you need too pretty much understand Php too get them working. And i have been banging my head against walls for 6mth in there forum, which only ever seem too send you too w3schools website. In my mind thats not support more being Fobbed Off! I came across this forum and seen there are people out there too help, and everyone here seems to enjoy helping unlike webassist. I have a few problems, my 1st is on the index page. When i run it i get this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') WHERE id = -1 AND ((type = 'Dog')) AND ((country = 'England')) LIMIT 0, 10' at line 1 i will add the index page for anyone too look at, thanks in advance of any help with this. [attachment deleted by admin]
×
×
  • 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.