-3

Im trying to update information into mysql by deleting the previous row then re-inputing my own data from a form. but im getting these errors:

Error:

 Warning: mysqli_query() expects parameter 1 to be mysqli, resource given in /home/a6620699/public_html/postv.php on line 29

 Warning: mysql_query(): 8 is not a valid MySQL-Link resource in /home/a6620699/public_html/postv.php on line 42

Code:

$con = mysql_connect("mysql2.000webhost.com","a6620699_oils","******");
if (!$con)
 {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("a6620699_oils", $con);

mysqli_query($con,"DELETE FROM Input WHERE id='1'");

$sql="INSERT INTO Imput (id, Imput) VALUES('1','$_POST[Vlink]')";

mysql_close($con);

if (!mysql_query($sql,$con))
 {
 die('Error: ' . mysql_error());
 }

echo "<br><br><br><br><br><center><h1>1 record added</h1></center>";

mysql_close($con)

.

<form action="postv.php" method="post">

Video Link: <input type="text" name="VLink" class="span12" /><br><br>

<input class="btn btn-large pull-right margin-top-15" type="submit" />
<input class="btn btn-small pull-left margin-top-15" type="reset" />

</form>
TheWebDev
  • 37
  • 1
  • 7
  • You're mixing two different libraries to manage a database in PHP. Read a book. –  Feb 02 '14 at 17:28
  • Post actual code in your question, not links to code – Mark Baker Feb 02 '14 at 17:28
  • @RobbyDuke Could you help me, not tell me "Read a Book" – TheWebDev Feb 02 '14 at 17:29
  • @MarkBaker I tried but it wasn't indenting, just adding spaces to the line above it. – TheWebDev Feb 02 '14 at 17:30
  • You remind me of my brother, you ask people for help without actually researching. An extremely simple google search would have told you in PLAIN text what you needed to know. –  Feb 02 '14 at 17:30
  • You're mixing your (SQL) functions. When you do get it going, read [`How can I prevent SQL injection in PHP?`](http://stackoverflow.com/q/60174/) before going LIVE. – Funk Forty Niner Feb 02 '14 at 17:51
  • This error message should have told its own story: Warning: mysqli_query() expects parameter 1 to be **mysqli** - parameter 1 as you have it is `mysql_connect` notice the missing `i` and inside all of your other `mysql_*` functions? – Funk Forty Niner Feb 02 '14 at 17:53

1 Answers1

0

For your SQL : Until the database is set with autocommit, you have to do commit or rollback manually. Don't forget this, otherwise you'll never see changes. (sorry for this tip, I have been using Oracle database without autocommit)

In you PHP: Form id = VLink Poster $_POST['Vlink'] : L in VLink is not uppercast as it is in your form

And finaly use mysqli_connect if you want mysqli_query else keep mysql_connect but use mysql_query. Don't mix both. Don't forget to look at php.net documentation, you have many exemples with mysql queries

edit : SQL is incorrect ! mysqli_query($con,"DELETE FROM Input WHERE id='1'"); -- table input

$sql="INSERT INTO Imput (id, Imput) VALUES('1','$_POST[Vlink]')"; -- here table imput

These are not the same tables ... so is field correct too (input or imput in INSERT statement)?

aviel
  • 178
  • 9