close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Insert not inserting!

Thread began 3/06/2016 10:02 pm by Warrio | Last modified 3/07/2016 4:04 pm by Ray Borduin | 1121 views | 2 replies |

Warrio

Insert not inserting!

Hi Ray,

I'm trying to capture the input of a search field and save it to the db any ideas

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$InsertQuery = new WA_MySQLi_Query($web_catalogues_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "searchphrases";
$InsertQuery->bindColumn("searchphrase", "s", "".((isset($_POST["zoom_query"]))?$_POST["zoom_query"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

I've even tried this
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$InsertQuery = new WA_MySQLi_Query($web_catalogues_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "searchphrases";
$InsertQuery->bindColumn("searchphrase", "s", "test phrase", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

Here is the full header info

<?php ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);?>
<?php require_once('../site_header_inc.php'); ?>
<?php require_once('../Connections/web_catalogues_i.php'); ?>
<?php require_once('../webassist/mysqli/rsobj.php'); ?>
<?php require_once('../webassist/mysqli/queryobj.php'); ?>
<?php
$rsCatalogue = new WA_MySQLi_RS("rsCatalogue",$web_catalogues_i,1);
$rsCatalogue->setQuery("SELECT * FROM catalogue WHERE catalogue.CatalogueID=?");
$rsCatalogue->bindParam("i", "".$_SESSION['catID'] ."", "-1"); //paramCatID
$rsCatalogue->execute();?>
<?php
$rsGrpMenu = new WA_MySQLi_RS("rsGrpMenu",$web_catalogues_i,0);
$rsGrpMenu->setQuery("SELECT * FROM view_menu_groups WHERE view_menu_groups.CatalogueID=? AND view_menu_groups.CatGrpActive<>0");
$rsGrpMenu->bindParam("i", "".$_SESSION['catID'] ."", "-1"); //paramCatID
$rsGrpMenu->execute();
?>
<?php
$rsBrandMenu = new WA_MySQLi_RS("rsBrandMenu",$web_catalogues_i,0);
$rsBrandMenu->setQuery("SELECT * FROM view_menu_brands WHERE view_menu_brands.BrandCatID=?");
$rsBrandMenu->bindParam("i", "".$_SESSION['catID'] ."", "-1"); //paramCatID
$rsBrandMenu->execute();
?>
<?php function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}?>
<?php $start_search = getmicrotime();?>
<?php
$rsFeatured = new WA_MySQLi_RS("rsFeatured",$web_catalogues_i,9);
$rsFeatured->setQuery("SELECT view_availablestockall.catAltText, view_availablestockall.catMenuLabel, view_availablestockall.catIcon, view_availablestockall.catDiscPrice, view_availablestockall.catDollarDisc, catRetailPrice, view_availablestockall.catItemDescShort, view_availablestockall.itemAvailable,view_availablestockall.catItemPrice, view_availablestockall.CatItemNameURL FROM view_availablestockall WHERE view_availablestockall.StkCatalogueID=? AND view_availablestockall.catMenuVisible<>0 AND MATCH(catItemDescLong) AGAINST ('" . $_GET['zoom_query'] ."' IN BOOLEAN MODE)");
$rsFeatured->bindParam("i", "".$_SESSION['catID'] ."", "-1"); //paramCatID
$rsFeatured->execute();
?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$InsertQuery = new WA_MySQLi_Query($web_catalogues_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "searchphrases";
$InsertQuery->bindColumn("searchphrase", "s", "".((isset($_POST["zoom_query"]))?$_POST["zoom_query"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

Cheers
Norman

Sign in to reply to this post

Ray BorduinWebAssist

Is your search using a "POST" method? Does the search itself work? It looks like it is implemented into your query with $_GET.

Try changing your insert to:

php:
<?php

if (isset($_GET["zoom_query"])) {
$InsertQuery = new WA_MySQLi_Query($web_catalogues_i);
$InsertQuery->Action "insert";
$InsertQuery->Table "searchphrases";
$InsertQuery->bindColumn("searchphrase""s""".((isset($_GET["zoom_query"]))?$_GET["zoom_query"]:"") ."""WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo "";
if (
function_exists("rel2abs")) $InsertGoTo $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

Warrio

DER!

Thanks Ray, maybe I should look at my code before posting!

Cheers
Norman

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...