0

I am getting the error

"Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in on line 21"

I have tried several different Queries none of which has worked. Any help would be appreciated!

Code:

<html><body>
<form action="attempt1.php" method="post">
Interest Rate: <input type="text" name="interest_rate"><br>

<input type="Submit">
</form>
<?php
$server = <removed for safety>;
$login = <removed for safety>;
$pass = <removed for safety>;
$interest_rate=$_POST['interest_rate'];

$dblink = mssql_connect($server, $login, $pass) or die("Error1"); 
 mssql_select_db('<removed for safety>', $dblink) or die( "unable to select the database");
 $sqlquery = "INSERT INTO interest_rate VALUES('$interest_rate')";
 $res = @mssql_query($sqlquery, $dblink);


$query=" SELECT * FROM 'interest_rate' ";
$result=mysql_query($query,$dblink) or die(mysql_error());
echo "<b>Output to table</b><br>";
echo "<table border='1'>
        <tr><th>Interest Rate</th></tr>";
while ($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['interest_rate'] . "</td>";

    echo "</tr>";

    echo $row['interest_rate'].""."<br>";
    }
echo "</table>";

?>
</body></html>
2
  • That code is really hard to read. Please set it as code... Commented Apr 10, 2011 at 19:49
  • What sort of database are you attempting to connect to? MySQL or MS SQL Server? Commented Apr 10, 2011 at 19:53

2 Answers 2

7

mysql_query is not mssql_query

Sign up to request clarification or add additional context in comments.

2 Comments

@middaparka: good job this is Sunday so I had a chance to get in first ;-)
The joy of being the early bird. (Enjoy your worms.) :-)
1

You are mixing stuff here.

This call:

mssql_select_db

And:

mssql_connect

Are for Microsoft SQL Server.

And you are trying to use with a mysql_query call. Decide whether you are using MySQL or SQLServer and pick function calls accordingly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.