Jump to content

undefined variable error & Fatal error


gsashwin

Recommended Posts

Hi,

 

    I am very new to PHP and I am trying to execute the below code but getting these errors :

 

 

Notice: Undefined variable: mysql_query in C:\wamp\www\process.php on line 16

 

Fatal error: Function name must be a string in C:\wamp\www\process.php on line 16

 

 

Code:

 

 

<html><body>

<?php

 

mysql_connect("localhost","root","");

mysql_select_db("encryption") or die(mysql_error());

 

$username = $_POST['username'];

$password = $_POST['password'];

 

$mysql_query("INSERT INTO login (username,password) VALUES ('$username','$password')") or die(mysql_error());

 

?>

</body></html>

`

$_POST['username']  &

$_POST['password'] come from a previous page. I have no problem with that. Please help.. Thanks in advance.

Link to comment
Share on other sites

You need to use mysql_query .. not $mysql_query(). In PHP variables start with a dollar, functions don't. That's what the second error is trying to tell you, and the first isn't technically an error but a notice; informing you that you're trying to use a variable that doesn't exist. Of course in this situation it's because it thinks you're trying to access the variable $mysql_query.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.