Mysql not updating [Resolved]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Mysql not updating [Resolved]

Post by Epiales »

Okay, I've spent a few hours trying to figure out why this isn't working. I can't find any errors visibly, and there are no errors displayed. So here I am lol....

Here is my isset function when they choose to update the information:

Code: Select all

$select = mysql_query("select * from locations LIMIT 1");

if(isset($_POST['update'])){
$UpdateQuery = "UPDATE locations SET location='$_POST[Location]', name='$_POST[Name]', price='$_POST[Price]', level='$_POST[Level]', greeting='$_POST[Greeting]', exitgreet='$_POST[ExitGreet]' WHERE id='$_POST[hidden]'";

mysql_query($UpdateQuery); 
Here is the input area that will be used for the isset:

Code: Select all

 <td>Location </td>
        <td><span class="div2">
          <input type="textarea" size="30" name="Location" id="Location" value= <?php echo $result['location'] ?> />
        </span></td>
        <td><!--DWLayoutEmptyCell-->  </td>
      </tr>
      <tr>
Here is the submit that will call the issset:

Code: Select all

 <?php echo '<input type=image value=Update image name=update img src="'  . '/adminpanelexample/images/user_edit.png">' ?>
Is it not working because of the limit one? I only want the first entry displayed is why I did it that way. Other than this, I have looked the code a billion times and find nothing wrong. Grrr Thx.

*EDITED* If you want to know the post hidden, here:

Code: Select all

<input type="hidden" name="hidden" id="edit5" value= "<?php echo $result['id'] ?>" />
Last edited by Epiales on Fri Aug 30, 2013 6:19 pm, edited 1 time in total.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Mysql not updating

Post by a_bertrand »

Beside your code like that is a HUGE security issue, I would simply print out the SQL you create and run it though phpmyadmin to show what's up.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Mysql not updating

Post by Epiales »

a_bertrand wrote:Beside your code like that is a HUGE security issue, I would simply print out the SQL you create and run it though phpmyadmin to show what's up.
Good idea...will do that...
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Mysql not updating

Post by Epiales »

Well I thought I would :lol:

Fairly new to most of this. Getting a working game going first, and then tear through the code to work on security. It's enough just getting something going to begin with for a fairly new coder. The game is up and running, and got loads of features already. Just working on an admin panel and then fix a few bugs I've seen. Then hopefully I can post the game here and have a few of ya test her out and give input and advice. The whole designs going to be redone. I have someone doing the design and stuff for me, but don't like it lol. Seems kind of plain, but I am new at this afterall, so I can't complain. :|

Is still, for the likes of me, can't see why it won't work. I'll spend some more time messing with it and give up for awhile. Could be, that when I start something, it is VERY hard for me to stop doing it for any amount of time. I get going, and it's got to be done. :lol: Thanks for the advice :)
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Mysql not updating

Post by a_bertrand »

Actually it's never a good idea to leave security for later, as it may mean the end of your site as soon as it's public. Also trying to fix things afterward means a lot more work.

So to avoid such cases as SQL injection, try to use MySQLi or PDO and bind variables. A good option is to use the class I made for it.

To avoid XSS check what htmlentities makes.

There is more security issues possible in a website but those 2 will already do some.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Mysql not updating

Post by Epiales »

What would be an example of using the htmlentities in the code I have displayed? If you don't mind?
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Mysql not updating

Post by a_bertrand »

in your example: not possible as you don't have any output from the DB.... so that would make no sense.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Mysql not updating

Post by Epiales »

a_bertrand wrote:in your example: not possible as you don't have any output from the DB.... so that would make no sense.
Well I have the users information being output to a form, where I just enter the information into the form and then it goes back to the database. My whole admin section is setup that way.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Mysql not updating

Post by a_bertrand »

The admin section is not what I would consider the most dangerous place for XSS attacks.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Mysql not updating

Post by Epiales »

Well, all I can do is :lol: :lol: :lol: :roll: :roll: :roll: :roll: :roll: :lol: :lol: :lol: :lol:

It would help if I had it in a form LOL. I think I need sleep :)

*RESOLVED* lol

Now if my access levels were that easy LOL YAY
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Post Reply

Return to “Beginner Help and Support”