Jump to content

simple script returning propper values but throwing error


danwoods

Recommended Posts

Hello all. It's been a while since I've hunkered down and had some fun with php, so I'm a little out of practice. I have what I think is a very simple script:

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
header('Content-Type: text/xml');

//connect with database
$con = mysql_connect("localhost","***","***");
if(!$con){
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("musicneverstopped", $con);
//end connecting to database

//declare placeholders
$artist = $_GET['artist'];

$result = mysql_query("SELECT * FROM artists WHERE name = '$artist'");

//error check - see if this is safe to remove later
if(!$result){
  die(mysql_error());
  }

//check if any results were returned
if(mysql_num_rows($result) > 0){
  
  while($row = mysql_fetch_array($result)){
    $response =  $row['abb'];
  	  }//end while

  }        

echo $response;

//close database connection
mysql_close($con);//close mysql connection


?>

 

When I call it and pass it a value it gives me an error like:

XML Parsing Error: syntax error

Location: http://localhost/MSNTesting/newDropDownFiles/php/artistToAbb.php?artist=John+Mayer

Line Number 1, Column 1:

jm

^

 

When "jm" is the proper return value. What could be causing this error? Thanks in advance...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.