PHP - Sqlsrv_ Conversion
Hi all,
Hopefully this will be a simple one for all you geniuses...Geniea... clever people out there. :? I'm trying to convert the following code from a mysql_ to sqlsrv_ statement. I have to admit i am a bit of a noob, but am learning fast! The code was originally developed by dreamweaver with some webassist extensions. $conn4 = sqlsrv_connect($hostname, $connectionInfo); 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 = sqlsrv_query($conn4, $WA_Sql) or die(print_r( sqlsrv_errors(), true)); $_SESSION[$WA_sessionName] = sqlsrv_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"]; } I appear to have had some luck with other parts of the code renaming mysql_ statements with the appropriate sqlsrv variations and some (slight) code re-hashing, but the above has given me a bit of a headache :banghead: . I assume that I need to break the "$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";" into two parts to give the sqlsrv_query it's `resource`, `array`, `parameter` format (I think that's right!), but i might be wrong. If it's all completely wrong, I apologise! Unfortunately due to the nature of the project Microsoft SQL is a necessary evil, and PDO has been considered but my brain is exploding with a (near straight) conversion as is... Unless anyone knows of a mysql to PDO conversion utility....or really easy method??? Would anyone be kind enough to help me with this? Regards Paladindc "In an ideal world, there would be no ideals, therefore would it indeed be ideal?" - Me Similar TutorialsHi, for my purposes, I can only use core PHP function (no PEAR for eg) to convert SQL to XML, should I convert SQL to csv first, and then use php's filesystem to read each line to extract and store as xml nodes OR does someone know easier/better method? Any help much appreciated, thanks. Good evening, I hope some of you can bring me some hope to solve this problem. My client wants to create pdf files and let the user download it. He want's to design one word file and then import it to the application. After that the portal users can request it, which means that the application should take the word file, search and replace some keywords and then create the pdf file for download purposes. I see fpdf but this class only create pdf's. We can not convert from word or even search and replace in one pdf file. There is any solution that i can use bear in mind that our application is located in external servers? Looking forward for your help. Regards, HS I don't really know how to explain this, I saw once on some forum members signature, something like this : G = "\ x50 \ x72 \ 157 \ 144 \ x75 \ x63 \ 164 \ x20 \ x6c \ x69 \ 143 \ 145 \ 156 \ x73 \ 145 \ 040 \ x68 \ 141 \ x73 \ 040 \ x65 \ x78 \ 160 \. 151 \ 162 \ x65 \ 144 \ x2e \ x20 "+ E. That somehow translates into words, I know there is a PHP function to convert that, what is that code called and what is the PHP function? I need to compare current time to data based time. Time in the database is in this format > 00:00:00 Easy enough. >>>>What I need is to convert "00:00:00" format into "time();" format<<<< The opposite is below...it's all I could come up with so far. <? $gettime = time(); $displayTime = date('H:i:s', time()); echo $displayTime; ?> Thank you. Can someone tell me how to convert a MySQL date such as 2010-08-13 into the the US format, such as 8/13/2010, and also the reverse using PHP? I can't seem to find the right functions. Thanks! Hello Freaks, Is there any possible way to convert a .PDF file to .html file without using any third party app and API?. I need That conversion fully made by PHP. Because i want to have full control on that conversion Help me with your opinion.. Thank You
I've been looking at converting my php timestamps to display as month, day, and the hour and minute the event occurred on, i tried; Code: [Select] $time = date("j/n H:i", $Events['timestamp']); But no success can anyone point me in the correct direction? Thanks I need a little help. I am trying to convert images taken from an upload form and convert them to jpg and then upload it to my directory. I tried GD but I cant figure out how to upload the converted file. I also tried using ffmpeg to convert the file but I am only able to do it with videos, I cant find the parameters for image to image conversion. Any input would be appreciated. Thanks Hello, Doing a little calendar where days are incremented as variable $i formatted like 'j' or single digit numbers 1,2,3 etc. (The calendar works fine) However for querying DB tables I need the day formatted as 'd' or 01,02,03 etc. so on any day I need to make this conversion. I can't find an easy solution though there must be one. Thanks in advance. Code: [Select] <?php //test day $i=7; $day=date('d', mktime($i)); echo "$day"; //Should be 07 ?> I am writing a script to read a mail box and fetch mail body using php function "imap_fetchbody". If mail content encoding is UTF-8 then no problem but mail send from IPAd having ascii encoding and replace the new line with =20 along with many other changes. can anyone help me out with this in converting it to UTF-8 ?? When pulling exif data from an image I have pretty much everythiung nailed down except for the Shutter Speed value. When pulled from the image this is returned as:- 'Shutter' => string '0.0015625' Now I know that the actual shutter speed at the time of shooting was 1/640 sec; does anyone have any ideas about how one would convert... 'Shutter' => string '0.0015625' to 1/640 sec... I have been scratching my head over this problem for a few days now and am stiull no wiser Hi all I've got an issue with time zones for displaying information. I'm hoping someone might know of a guide that would cover the following. I'm struggling to find one! Basically I have many online events to list in many different timezones. Users may wish to use their time zone to display information in. What I would like to do is store a timestamp and timezone for each event, then will need (I think!) to convert all to a single timezone in order to list them chronologically. From that I would then convert them into the user's desired timezone and display to the page. The idea to is avoid changes in time throughout the year, so it does it all automatically. Any links, tips, words of advice very gratefully received! I'm pulling some info from various XML files and am having problems converting the following date format so that it can be stored as a DATETIME field in a MySQL database. Tuesday,17 August 2010 09:25:00 This obvious newbie would appreciate a shove in the right direction... Thanks in advance hey guys the date stored in mysql is yyyy-mm-dd i need to convert it to do a string compare i have used the following $query = "SELECT * FROM booking where id=$sel"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $num1=$row['no_rooms']; $from1=$row['from']; $to=$row['to']; $sel1=$row['room_type']; $date = date('d-m-y', strtotime($from1)); } echo "$date"; it prints 01-01-70 can any1 tell me where is the error? thanks How can I get rid of "Notice:Array to string conversion on line 78" error from this code? can i get a little help please? This is line 78 : $table .= $columnValue; Basically this code's supposed to do is to group the values from grpa, grpb of datatb to 4 different categories according to their value. and as end result, category index number of each category is put into the html table. Thanks.
<?php include ("configd.php"); $sql = "SELECT grpa, grpb From datatb"; $result = $conn->query($sql); //categories $cat = [ 4 => [1, 2, 3, 4], 3 => [5, 6], 2 => [7, 8], 1 => [9, 10] ]; while ($row = $result->fetch_assoc()) { foreach ($cat as $catKey => $catValue) { $columns[$catKey] = array_filter($row, function ($col) use ($cat, $catKey) { if (in_array($col, $cat[$catKey])) { return true; } }); } $output[] = $columns; } // the output $table = <<<EOT <table class='maintable'> <tr><th>9:10</th></tr> <tr><th>7:8</th></tr> <tr><th>5:6</th></tr> <tr><th>1:4</th></tr> </table> EOT; foreach ($output as $row) { $table .= "<table class='maintable'>"; foreach ($row as $columnKey => $columnValue) { $table .= "<tr>"; $table .= "<td>"; $table .= $columnValue; $table .= "</td>"; } $table .= "</tr>"; $table .= "</table>"; } echo $table; ?> Edited June 30, 2020 by mattix small additions. I have an application where things are requested/computed/shown using either Metric or English systems.
I am thinking that the best way to handle this is to store units in one system, i.e English (as I am in United States), and to only convert them to Metric for the View, when it is being requested.
And if Metric parameters are being inputted through a form, then convert them to English on input.
So in a word
* store, compute, anything back-end, do it in English system.
When anything Metric shows up, then
* convert-on-output to Metric
* convert-on-input from Metric
Does that sound like a good plan?
Are there any other equally or better-than plans to deal with systems?
//$start_point = '2014-07-22'; $lastday = date('t',strtotime($start_point)); $month_val = date('n',strtotime($start_point)); echo "Last day: ". $lastday . "<br/>"; echo "Month: ". $month_val . "<br/>";I have a problem with a date value read from a MySQL database table into a PHP variable but when manipulating the vale to determine the month of the date, unexpected results appear. I am not sure what causes this but I suspect PHP is not properly handling date to string conversion. The output from the code shows 1 as the month when it should be 7. Hower the line of code with the comment "//$start_point = '2014-07-22' if added in give the correct result. When the value of the variable "start_point" is printed, it gives the value "2014-07-22". Please see the code Telly Hi; I'm a beginner and I'm getting a big headache figuring how to convert php variables into Javascript variables. I want to use the content of $theName as the value for an input tag. $_SESSION['$Sess_Name'] is loaded with the right data, I verified it. But my function InitField returns always the word NULL. Why is that? Where is the problem? Thank Here is my code: function InitField() { <?php Hi - I have been searching for a way to select the stored time from a database (stored in 24h format - 13:20:00) and display it as 12h format. I have checked a number of forums and nothing quite seems to fit the bill. I would like it to display as 2:00pm, 12:00am, etc. Here is what I have so far: $sql = ('SELECT * FROM events WHERE active="1" AND event_date >= CURRENT_DATE AND MONTH(event_date) = 1 order by event_date ASC, event_start ASC'); $result = mysql_query($sql); $num_rows = mysql_num_rows($result); // Yes Item if (!($num_rows == 0)) { $myrow = mysql_fetch_array($result); echo ('<span class="bold" style="font-size:14px">January</span>'); do { printf ('<span>Event Time: %s', $myrow['event_start']); if ($myrow['event_end'] != '') { printf (' to %s', $myrow['event_end']); } } while ($myrow = mysql_fetch_array($result)); } Right now this just shows the regular 24h format (hh:mm:ss) for any events in the month of January. I would like both "event_start" and "event_end" to show up in 12h format. I have tried a number of things but none of it works. I'm SURE it is something simple that I have missed. Thanks in advance for any help. |