Jump to content

Php Sql INSERT not inserting a new value on the data table


BrentMichie

Recommended Posts

I have a program which is attempting to valid a username and password.  Basic login, signup stuff.  I have two working php files which query a database.  The first one queries database A to check if an email exists.  The second one queries database B to check if the password entered for a given email address is the same as user provided one.  Both of these work.  I am trying to make a 3rd php file which adds a value to the database.  I am trying very simply to add an email address to database A.  The code executes fine up until the Insert line.  I am reasonably certain that the database is connecting because if I replace the Insert line with a similar SELECT line it can locate the email in the database just fine.  I have checked and re-check my $sql = " "; statement many different websites proclaim that to be the correct syntax.  I know that the code inside the sql statement is working because when I go on the web server and input the code inside the sql quotations it adds a datapoint to the table. 

Can somebody please take a look at my syntax and see if there is something I have missed?

My webhosting is through godaddy.com and the user that I have connecting to this database has full permissions granted through their hosting management.  I'm using phpMyAdmin to view the database tables and to manually insert new values for the tables.  All php files are stored on my web server in the public_html folder and I execute them by using myurl.com/player_signup.php etc (as I said earlier, this works for 2/3 so I don't think there is issues with where I have placed the files).

 

When I execute the code below the echo returns

Error: INSERT INTO rdfz VALUES('fasfasfasddf')

 

I've been staring at this problem all day.  If someone could give me any direction that could help I would appreciate it very much.

SS.PNG

Link to comment
Share on other sites

Your real problem is that you are using dangerous obsolete code that has been completely removed from PHP. You need to use PDO with Prepared Statements. There is no "fixing" this code. This tutorial will get you going. https://phpdelusions.net/pdo

You are also mixing mysql with mysqli. Whatever "tutorial" you are following, toss it.

And next time post the actual code using the code tags. Pictures are for hanging on the wall.

Link to comment
Share on other sites

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.