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

  • Home
  • SEARCH
  • 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 756655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:16:12+00:00 2026-05-14T15:16:12+00:00

Been trying this for quite a while now and I need help. Basically I

  • 0

Been trying this for quite a while now and I need help. Basically I have a PHP file that queries database and I want to change the query based on a logged in users name.

What happens on my site is that a user logs on with Twitter Oauth and I can display their details (twitter username etc.). I have a database which the user has added information to and I what I would like to happen is when the user logs in with Twitter Oauth, I could use jQuery to take the users username and update the mysql query to show only the results where the user_name = that particular users name.

At the moment the mysql query is:

"SELECT * FROM markers WHERE user_name = 'dave'"

I’ve tried something like:

"SELECT * FROM markers WHERE user_name = '$user_name'"

And elsewhere in the PHP file I have $user_name = $_POST[‘user_name’];. In a separate file (the one in which the user is redirected to after they log in through Twitter) I have some jQuery like this:

$(document).ready(function(){
$.post('phpsqlinfo_resultb.php',{user_name:"<?PHP echo $profile_name?>"})});

$profile_name has been defined earlier on that page.

I know i’m clearly doing something wrong, i’m still learning. Is there a way to achieve what I want using jQuery to post the users username to the PHP file to change the mysql query to display only the results related to the user that is logged in. I’ve included the PHP file with the query below:

    <?php
// create a new XML document
//$doc = domxml_new_doc('1.0');
$doc = new DomDocument('1.0');

//$root = $doc->create_element('markers');
//$root = $doc->append_child($root);
$root = $doc->createElement('markers');
$root = $doc->appendChild($root);
$table_id = 'marker';
$user_name = $_POST['user_name'];
// Make a MySQL Connection
include("phpsqlinfo_addrow.php");
    $result = mysql_query("SELECT * FROM markers WHERE user_name = '$user_name'")
    or die(mysql_error());
// process one row at a time
//header("Content-type: text/xml");
header('Content-type: text/xml; charset=utf-8');
while($row = mysql_fetch_assoc($result)) {
    // add node for each row
  $occ = $doc->createElement($table_id);
  $occ = $root->appendChild($occ);
  $occ->setAttribute('lat', $row['lat']);
  $occ->setAttribute('lng', $row['lng']);
  $occ->setAttribute('type', $row['type']);
  $occ->setAttribute('user_name', utf8_encode($row['user_name']));
  $occ->setAttribute('name', utf8_encode($row['name']));
  $occ->setAttribute('tweet', utf8_encode($row['tweet']));
  $occ->setAttribute('image', utf8_encode($row['image']));
} // while
$xml_string = $doc->saveXML();
$user_name2->response;
echo $xml_string;
?>

This is for use with a google map mashup im trying to do. Many thanks if you can help me. If my question isn’t clear enough, please say and i’ll try to clarify for you. I’m sure this is a simple fix, i’m just relatively inexperienced to do it. Been at this for two days and i’m running out of time unfortunately.

  • 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-14T15:16:12+00:00Added an answer on May 14, 2026 at 3:16 pm

    At first, you should escape the $_POST you’re inserting straight to the query:

    'SELECT * FROM markers WHERE user_name = `' . mysql_real_escape_string($user_name) . '`';
    

    As Erik suggests, don’t throw out of the window the most useful warnings – most probably the answer will pop right ahead then.

    But what I’m not quite sure about is the way your mashup works. It could get a lot easier if you just do all the stuff inside the php itself, omitting javascript at all. You might also want to check OAuth callbacks – should give you twitter id or user name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 430k
  • Answers 430k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Adding a call to chmod in before-save-hook would be clean… May 15, 2026 at 1:52 pm
  • Editorial Team
    Editorial Team added an answer I wrote some blog posts about NSURLConnection. Using NSURLConnection Sending… May 15, 2026 at 1:52 pm
  • Editorial Team
    Editorial Team added an answer It really depends on how you interact with the structures… May 15, 2026 at 1:52 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.