converting a php script for mySql to microsoft sql


HOME ยป Databases
I have a script that is designed to work with mysql and i need it to
work with microsoft sql. I have already built a web app using mvc and
have it connecting to the database. i have also built a mobile app
using a software called App inventor 2 shich just uses code blocks. I
need the mobile app to connect to the same database but in order to do
so i have to use a php script but the problem is this script is wrote
for mysql and i am using microsoft sql. I have never used php before
and am wondering is there much involved to change the script so it
will work with microsoft sql.
Syntax: [ Download ] [ Hide
]SXBB[id].writeCmd();Syntax: [ Download ] [ Show
][syntax=php]&
I have a script that adds users into a mysql database for a game. />I found an updated version of the game, but it uses sqlite for some
reason.
Could anyone help me convert it to sqlite? Thanks! />Here's the script I'm talking about:
Update: by the way, I
use php4
Syntax: [ Download ] [ Hide ]SXBB[id].writeCmd();Syntax:
[ Download ] [ Show ]<?
   /* author: Adam
Lindquist; written: Jan  5, 2004
     
modded: Adam Lindquist;          Jan 24,
2004
              desc: made
the script more modular
 
Databases
Hi, I've been given a backup file of MS SQL 2000, I need to convert it
to a MySQL database... any ideas on how i can do that?
Thanks!
Databases
I have a script that is designed to work with mysql and i need it to
work with microsoft sql. I have already built a web app using mvc and
have it connecting to the database. i have also built a mobile app
using a software called App inventor 2 shich just uses code blocks. I
need the mobile app to connect to the same database but in order to do
so i have to use a php script but the problem is this script is wrote
for mysql and i am using microsoft sql. I have never used php before
and am wondering is there much involved to change the script so it
will work with microsoft sql.
Syntax: [ Download ] [ Hide
]SXBB[id].writeCmd();Syntax: [ Download ] [ Show
][syntax=php]&
Databases

i want to import my backup database(.sql file) into mysql using php
script. i have given the following code where case 1 section works.
but i need to execute case 0 section. what the problem in my code
please help me anyone.

<?php//ENTER THE RELEVANT INFO
BELOW$mysqlDatabaseName ='online_admission_form';$mysqlUserName
='root';$mysqlPassword ='';$mysqlHostName
='localhost';$mysqlImportFilename
='db-backup-1360387884-770ac5920c7155e73215540b30ed1c18.sql';//DONT
EDIT BELOW THIS LINE//Export the database and output the status to the
page$command='mysql -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p'
.$mysqlPassword .' ' .$mysqlDatabaseName .' < ' .$mysqlImportFilen
PHP

I have 2 queries that are kicking my butt in the conversion. Anyone
feel like slapping me in the back of the head and telling me what I am
doing wrong?



select 
d.dat,
c.cid,
c.type,
c.interface,
c.count,
mm.mp as multiplier,
(c.count * mm.mp) `mbps`
from
cap c
left join
(select distinct tid, cid, type, interface, concat(tid, ' * ',
cid, ' * ', type, ' * ', interface) as node from cap)cc
on cc.tid = c.tid and cc.cid = c.cid and cc.type = c.type and
cc.interface = c.interface
left join
(select distinct type, CASE WHEN type = 'STS1' THEN 51.84 WHEN
type regexp 'STS3' THEN 51.84*3 WHEN type regexp 'STS12' THEN 51.84*12
ELSE 1.728 END AS mp from cap) mm
on mm.type = c.type
left join
(select tid, cid, type, interface, date_time as dte,
substring(`date_time`, 1, 10) as dat from cap) d
on c.tid = d.tid and c.cid = d.cid and c.type = d.type and
c.interface = d.interface and c.`date-time` = d.dte
where
d.dat = '11/03/2014' and (c.count * mm.mp * cl.incl) > 0 and
c.cid not regexp '/'
order by
d.dat,
c.cid,
c.type
Web Development

Thanks in advance for your help. I have a landing page with an AJAX
email collection form in the first section which I have adapted from
this href="http://code.tutsplus.com/tutorials/building-a-sleek-ajax-email-signup-form--net-13645"
rel="nofollow">Tutsplus tutorial.



However, the PHP section of the form is written in MySQL which is
not compatible with my Heroku server as it is deprecated. Taking
advice from others on stackoverflow, I tried converting the MySQL
statements in my code to PDO. But have difficulties getting the form
to work.



Here is the original working MySQL code



<?php
if($_GET['action'] == 'signup'){
// if(isset($_GET['action'])&& $_GET['action'] == 'signup'){

mysql_connect('hostname','username','password');
mysql_select_db('databasename');

$email = mysql_real_escape_string($_POST['emailfield']);

//validate email address - check if input was empty
if(empty($email)){
$status = "error";
$message = "You did not enter an email address!";
}
else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ //validate email
address - check if is a valid email address
$status = "error";
$message = "You have entered an invalid email address!";
}
else {
$existingSignup = mysql_query("SELECT * FROM table WHERE
signup_email_address='$email'");
if(mysql_num_rows($existingSignup) < 1){

date_default_timezone_set('Asia/Singapore');
$date = date('Y-m-d');
$time = date('H:i:s');

$insertSignup = mysql_query("INSERT INTO table
(signup_email_address, signup_date, signup_time) VALUES
('$email','$date','$time')");
if($insertSignup){ //if insert is successful
$status = "success";
$message = "You have been signed up!";
}
else { //if insert fails
$status = "error";
$message = "Oops, Theres been a technical error!";
}
}
else { //if already signed up
$status = "error";
$message = "This email address has already been registered!";
}
}

//return json response
$data = array(
'status' => $status,
'message' => $message
);

echo json_encode($data);
exit;
}
?>





And here is my failed attempt to convert the above MySQL code to
PDO





<?php
if(isset($_GET['action'])&& $_GET['action'] == 'signup'){

try {
$db = new
PDO('mysql:host=hostname;dbname=dbname;charset=utf8','user','pwd');
}
catch(exception $e) {
echo "Error, connection failure";
}

$email = $_POST['emailfield'];

//validate email address - check if input was empty
if(empty($email)){
$status = "error";
$message = "You did not enter an email address!";
}
else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ //validate email
address - check if is a valid email address
$status = "error";
$message = "You have entered an invalid email address!";
}
else {

$existingSignup = "SELECT COUNT(*) FROM table WHERE
signup_email_address='$email'";
if ($res->fetchColumn() < 1) {

date_default_timezone_set('Asia/Singapore');
$date = date('Y-m-d');
$time = date('H:i:s');

$insertSignup = "INSERT INTO table (signup_email_address,
signup_date, signup_time) VALUES (:signupemail, :signupdate,
:signuptime)";

$query = $db->prepare($insertSignup);
$query->bindParam(':signupemail', $email);
$query->bindParam(':signupdate', $date);
$query->bindParam(':signuptime', $time);
$results = $query->execute();

if($insertSignup){ //if insert is successful
$status = "success";
$message = "You have been signed up!";
}
else { //if insert fails
$status = "error";
$message = "Oops, Theres been a technical error!";
}
}
else { //if already signed up
$status = "error";
$message = "This email address has already been registered!";
}
}

//return json response
$data = array(
'status' => $status,
'message' => $message
);

echo json_encode($data);
exit;
}
?>





Would you give me advice in correcting my PDO code? Thanks!

Web Development

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow