Avatar of ritschel
ritschel

asked on 

PHP translation to Classic ASP

Please translate the PHP code to Classic ASP.  I do not know PHP at all and I am trying to get an AJAX fuction to work in ASP.  The translation will help me do that.  Thanks for your help!
<?php 
if(empty($_GET['topic'])) {   
	exit(); 
} 
$topic = $_GET['topic']; 
$link = mysql_connect("localhost","username","password"); 
mysql_select_db("database_name"); 
 
 
$query = "SELECT item FROM info WHERE cat = '".mysql_real_escape_string($topic)."'";  
$result = mysql_query($query); 
 
if($result) { 
	$items = array(); 
 
	while($row = mysql_fetch_array($result)) {       
		$items[] = $row['item']; 
	} 
 
$string = implode(',',$items); 
echo $string; 
} 
?>

Open in new window

ASPPHP

Avatar of undefined
Last Comment
kevp75
Avatar of kevp75
kevp75
Flag of United States of America image

if len(request("topic")) > 0 then

set objConn = CreateObject("Adodb.Connection")
   objConn.Open strYourConnectionStringHere
      set objRS = objConn.Execute("SELECT item FROM info WHERE cat = '" & replace(request("topic"),"'","")) & "'")
         if not(objRS.EOF) then
            do while not(objRS.EOF)
                response.write(objRS("item"))
                objRS.MoveNext
            loop
          else
               response.write("No Records Found")
           end if
       set objRS = nothing
    objConn.Close
set objConn = Nothing
ASKER CERTIFIED SOLUTION
Avatar of kevp75
kevp75
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ritschel
ritschel

ASKER

Thanks for your quick response!
Avatar of kevp75
kevp75
Flag of United States of America image

thatnks for the grade....glad I could help :)
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo