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 7930721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:30:52+00:00 2026-06-03T20:30:52+00:00

I’m making a PHP and MySQL RPG game, and my changeEquipment page is not

  • 0

I’m making a PHP and MySQL RPG game, and my changeEquipment page is not working. I’m getting these errors:

Warning: mysql_query() [function.mysql-query]: Access denied for user
‘devinfa1’@’localhost’ (using password: NO) in
/home/devinfa1/public_html/spellsword/changeEquipment.php on line 21

Warning: mysql_query() [function.mysql-query]: A link to the server
could not be established in
/home/devinfa1/public_html/spellsword/changeEquipment.php on line 21

Warning: mysql_query() [function.mysql-query]: Access denied for user
‘devinfa1’@’localhost’ (using password: NO) in
/home/devinfa1/public_html/spellsword/changeEquipment.php on line 27

Warning: mysql_query() [function.mysql-query]: A link to the server
could not be established in
/home/devinfa1/public_html/spellsword/changeEquipment.php on line 27

Here’s my code:

<?php
// Get commonFunctions.php
require_once('commonFunctions.php');

// Start the session and connect to the database
session_start();
$con = mysql_connect("localhost","devinfa1_user","dbpass");
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("devinfa1_spellsword", $con);   

// If logged in
if(isset($_SESSION['account_name'])) {
    // If form is submitted
    if(isset($_POST['submit']) || isset($_POST['submit_x'])) {

        // If the hero has more than one weapon
        if(hero_has_multiple_weapons()) {
            // Set new weapon
            mysql_query("UPDATE Hero_Weapons SET active_weapon = TRUE WHERE HW_hero_id =
                (SELECT hero_id FROM Heroes WHERE hero_name = '$_SESSION[hero_name]')
                AND HW_item_id = (SELECT item_id FROM Items WHERE item_name = '$_POST[weapon]')");

            // Unset previous weapon
            if(isset($_SESSION['hero_name'])) {
                mysql_query("UPDATE Hero_Weapons SET active_weapon = FALSE WHERE HW_hero_id =
                    (SELECT hero_id FROM Heroes WHERE hero_name = '$_SESSION[hero_name]')
                    AND HW_item_id = (SELECT item_id FROM Items WHERE item_name = '$_SESSION[weapon_name]')");
            }
        }

// Close the database connection
mysql_close($con);
?>

So, the PHP should be connecting to my databse using the devinfa1_user username and dbpass password, but it’s apparently trying to use the devinfa1 username with no password.

I have no idea why this is the case, because I have the exact same connection code and an update statement on my changeHero page and it works perfectly. Any ideas?

  • 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-06-03T20:30:54+00:00Added an answer on June 3, 2026 at 8:30 pm

    Pass the connection in with the query, per the manual : The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated.

    see if that works, it looks as if is overriding the last connection (ie in the call to hero_has_multiple_weapons() a db connection is opened) or your last connection didnt really connect

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.