Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6088803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:01:41+00:00 2026-05-23T12:01:41+00:00

I am trying to generate some xml with this php code here… I am

  • 0

I am trying to generate some xml with this php code here… I am trying to use this script for an ios app I am learning from as I go just to figure out how each of the parts fit i.e. (app, php, mysql, xml)

Here is my php script that my ios app is exicuting

<?php

header("Content-type: text/xml"); 

$username="*****";
$password="***";
$database=" *****";

$testcode=$_REQUEST['usercode']; ////testcode coming from ios app

//connect to database
$connect = mysql_connect('localhost',$username,$password) or die('No DB Connection');
//select database
$db = mysql_select_db('N_codes', $connect) or die("<b>Unable to select specified database</b>");


//Do some stuff here
$query = "SELECT codes FROM codes where id = '$testcode'"; //testcode coming from ios app
$result = mysql_query($query,$connect);


//XML STUFF

$xml_output = "<?xml version=\"1.0\"?>\n"; 
$xml_output .= "<entries>\n"; 

$row = mysql_fetch_assoc($result); 

$xml_output .= "\t\t<code>" . $row['codes'] . "</code>\n"; 

$xml_output .= "</entries>"; 

echo $xml_output; 


?>

This is all that it is producing

<?xml version="1.0"?>
<entries>
        <code></code>
</entries>

What I am looking for is a code that should be between that is in the mysql database and is found by the user supplying a code that is passed to the php script.

Can anyone see whats missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:01:41+00:00Added an answer on May 23, 2026 at 12:01 pm

    I see a few "potential" problems with the code you provided above.

    1. Is your table named codes and the field you’re looking for also codes? Your SQL question is looking for a field name codes in a table called codes. It’s hard to tell whether or not that’s a problem but must rows represent a single field so the plural version of the word "code" makes me believe you made a mistake there.

    $query = "SELECT code FROM codes where id = '$testcode'";
    

    2. Try adding a die after the query that outputs [mysql_error][2] just in case an error occurred.

    $result = mysql_query($query, $connect) or die(mysql_error($connect));
    

    3. You should use mysql_real_escape_string when you use user supplied data in a SQL query.

    $testcode = mysql_real_escape_string($_REQUEST['usercode'], $connect);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use XSLT to generate some XHMTL with inline PHP. I've run
I am trying to use the tool XSD.EXE to generate some class files from
I'm trying to write a simple pylons action to generate some xml. Here's the
I'm trying to use XSL-stylesheets in order to transform some generated XML-data to HTML-output.
I'm trying to generate some code at runtime where I put in some boiler-plate
I am trying to generate some code at runtime using the DynamicMethod class in
I am trying to generate some code using CodeDom. I wanted to know if
currently i'm trying to use imagick to generate some images without saving them on
I'm trying to generate code coverage reports with EMMA using tests of which some
I'm trying to write some LINQ To SQL code that would generate SQL like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.