close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

couple of msql conversion

Thread began 5/04/2018 12:04 pm by Jamie | Last modified 5/09/2018 4:39 pm by Ray Borduin | 46 views | 7 replies |

Jamie

couple of msql conversion

Hi Ray

Am trying to convert this to mysqli to show the date in a UK format in a datepicker input -

<?php echo((isset($_GET["invalid"])?ValidatedField("blogupdate","BlogDate"):"".(($row_WADAblog["BlogDate"] != "")?date("d-m-Y",strtotime($row_WADAblog["BlogDate"])):date("d-m-Y"))."")); ?>



have tried changing to this but no joy

<?php echo((isset($_GET["invalid"])?ValidatedField("blogupdate","BlogDate"):"".(($WADAblog("BlogDate") != "")?date("d-m-Y",strtotime($WADAblog("BlogDate"))):date("d-m-Y"))."")); ?>



Also, I am trying to convert this to mysqli with no joy

<?php } while ($row_WADAtemplate = mysql_fetch_assoc($WADAtemplate)); ?>

<?php } ?>



Cheers

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

Should be:

php:
<?php echo((isset($_GET["invalid"])?ValidatedField("blogupdate","BlogDate"):"".(($WADAblog->getColumnVal("BlogDate") != "")?date("d-m-Y",strtotime($WADAblog->getColumnVal("BlogDate"))):date("d-m-Y"))."")); ?>



The second code is just a repeat region... you should be able to delete those lines and highlight the same area of code and apply the mysqli repeat region to get the equivalent code.

Sign in to reply to this post

Jamie

thanks Ray - works great

As am going through the various pages to convert, have another one that am unsure how to convert to mysqli where the database connection is $DBConnection:

<?php
function cmp($a, $b) {
return ($a[2] < $b[2] || ($a[2] == $b[2] && $b[2] == $b[1]))? -1: 1;
}
if (isset($_POST["UpdateOrder"])) {
mysql_select_db($database_PowerCMSConnection, $PowerCMSConnection);
$OrderArray = array();
$start = 1;
while (isset($_POST["FaqID_".$start])) {
$OrderArray["Products_". $_POST["FaqID_".$start]] = array($_POST["FaqID_".$start],$start,$_POST["FaqOrder_".$start]);
$start ++;
}
$start = 1;
uasort($OrderArray, "cmp");
foreach ($OrderArray as $Products) {

mysql_query("UPDATE faqs SET FaqOrder = ". $start ." WHERE FaqID = " . intval($Products[0]), $PowerCMSConnection) or die(mysql_error());
$start++;
}
}
?>
Sign in to reply to this post

Ray BorduinWebAssist

You can delete teh mysql_select_db() line.

Then you just have to update the code for the mysql_query() line.

You should be able to apply the mysqli update server behavior and
set the FaqOrder value to <?php echo($start); ?>
and FaqID to <?php echo($Products[0]); ?>

Then just replace the mysql_query() line with the new update code.

Sign in to reply to this post

Jamie

many thanks Ray

which bit of the update code do I replace that with

I have

<?php
if (false) {
$UpdateQuery = new WA_MySQLi_Query($DBConnection);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "faqs";
$UpdateQuery->bindColumn("FaqID", "i", "".($Products[0]) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("FaqOrder", "i", "".($start) ."", "WA_DEFAULT");
$UpdateQuery->addFilter("FaqID", "=", "i", "".($_GET['FaqID']) ."");
$UpdateQuery->execute();
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>



and updated the original code to this but it doesnt reorder the content

<?php
function cmp($a, $b) {
return ($a[2] < $b[2] || ($a[2] == $b[2] && $b[2] == $b[1]))? -1: 1;
}
if (isset($_POST["UpdateOrder"])) {
$OrderArray = array();
$start = 1;
while (isset($_POST["FaqID_".$start])) {
$OrderArray["Products_". $_POST["FaqID_".$start]] = array($_POST["FaqID_".$start],$start,$_POST["FaqOrder_".$start]);
$start ++;
}
$start = 1;
uasort($OrderArray, "cmp");
foreach ($OrderArray as $Products) {

$UpdateQuery = new WA_MySQLi_Query($DBConnection);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "faqs";
$UpdateQuery->bindColumn("FaqID", "i", "".($Products[0]) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("FaqOrder", "i", "".($start) ."", "WA_DEFAULT");
$UpdateQuery->addFilter("FaqID", "=", "i", "".($_GET['FaqID']) ."");
$UpdateQuery->execute();
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
}
?>
Sign in to reply to this post

Ray BorduinWebAssist

To match your original the lines should be:

$UpdateQuery = new WA_MySQLi_Query($DBConnection);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "faqs";
$UpdateQuery->bindColumn("FaqOrder", "i", "".($start) ."", "WA_DEFAULT");
$UpdateQuery->addFilter("FaqID", "=", "i", "".(Products[0]) ."");
$UpdateQuery->execute();
$UpdateGoTo = "";
Sign in to reply to this post

Jamie

thanks for that but on submitting it doesnt change anything at all. have attached the file if you need the context and put the link to the site in the PM

Sign in to reply to this post

Ray BorduinWebAssist

You removed this line in the loop:

$start++;

That had to stay. I've added it back and the page works now.

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...