No PHP connection response

Asked

Viewed 27 times

-2

Good evening, could someone help me? I’m doing an academic project where I have to link HTML pages and make them pull information from the database.

So far, I have created a table in my database, created a php script to connect and put the form in the html page as a button. When I click the button it brings me the php code on a web page. Can anyone help me?

 isso que aparece na imagem

Obs: the file is as php and I am opening the web page and on the web page I am pressing the button.

  • 1

    Hello Aleeh, Welcome to the forum. I suggest you read the tour (https://answall.com/tour) to see how things work here in the community. So that the people can help you here are 2 tips: Put the code through the shortcut ctrl + k and not an image. Another tip is to clarify what your problem is.

1 answer

1

In connection with the BD, you are passing a "variable" $123, but variable names in PHP cannot start with numbers and in this case it is not even being declared. I think you wanted to write $senha. The same goes for $servidor and $usuario.

$link = mysql_connect($servidor, $usuario, $senha);

Also, I don’t know what version of PHP you’re using, but mysql_connect was deprecated in version 5.5.0 and removed in version 7.0.0. From documentation:

This Extension was deprecated in PHP 5.5.0, and it was Removed in PHP 7.0.0

FUNCTION mysqli_connect

You can use mysqli_connect (note the i next to the word mysql - i is of improved/improved).

$link = mysqli_connect($servidor, $usuario, $senha, $banco);

Optionally, you can use mysqli_select_db to connect to the BD. In this case, do not add the parameter $banco in mysqli_connect.

MORE FUNCTIONS

You can search for more functions in the PHP documentation here. There is even the option to use the class mysqli (object orientation).

  • I already changed the code to mysqli, but the execution remains the same. Is my form correct? <div id="content-wrap"> <div id="content" class="clearfix"> <H3 class="Yellow F14">See candidates:</H3> <form name="Register" action="query.php" method="POST"> <input type="Submit" name="query-complete" value="See here"> </form> </div>

  • The script you posted only opens the connection to the BD. If there are no errors appearing on the page (and the Debugger is active) there are no errors. But check the password, and BD connection user. Post the rest of your code to try to help. You can edit your question and post on it.

  • In the script you posted is not being searched in DB. You need to use mysqli_query to execute your SELECT.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.