1

I have created a table in SQLDeveloper, populated it with user data (Username, email, password, password) in PHP and am able to delete user data as well. Now what I want to do is modify data in table. The only syntax I can find online is that for MySQL and I'm trying to fix it so it can work in SQLDeveloper. This is the code I'm using that's set up for MySQL.

My Table is called MANCITY and the only thing I wish to update is the customer username. I've left it in MySQL form rather than have a mix of some things I think may be right fo SQLDeveloper and get myself mixed with the two. Thanks!

<?php

$dbuser = "s";
$dbpassword = "t";
$db = "o";

$con=mysqli_connect("$dbuser,$dbpassword,$db");

if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

mysqli_query($con,"UPDATE MANCITY SET USERNAME=JOHN
WHERE USERNAME='JON' AND EMAIL='[email protected]'");

mysqli_close($con);
?>

Edit:

My main issue is how to change it so it can connect to my Oracle database.

7
  • Sidenote: You're missing the host parameter for your DB credentials. General syntax is $con = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); no quotes. Commented Mar 25, 2014 at 23:19
  • Sorry, maybe I didn't put across my problem well. You see, that's code for MySQL I'm sure I can't use "mysqli();" when I'm trying to get it to connect to my SQLDeveloper database. My main issue is how to change it so it can connect to my Oracle database. Commented Mar 25, 2014 at 23:24
  • I edited your question with your comment as well as adding the relevant "Oracle" tag. In the future, please add all relevant information, so that people (including myself) won't be misled and give incorrect answers, as I did; which I ended up deleting my answer. @user3457441 Welcome to StackOverflow ;-) Commented Mar 25, 2014 at 23:29
  • This is an Oracle DB connection example $con=oci_connect("system","123","localhost/orcl"); the rest of the queries resemble themselves a lot. Have you Google'd Oracle SQL? Commented Mar 25, 2014 at 23:32
  • Sorry, I thought "using SQLDeveloper instead of MySQL" was clear enough. I haven't google "oracle" instead I've been looking for SQLDeveloper specifically because I wasn't sure if Oracle was too vague. Commented Mar 25, 2014 at 23:34

1 Answer 1

1

You may either use PDO with the Oracle driver, which has the advantage that you can practically read any PDO-PHP tutorial and most likely will only need to change the line which constructs the PDO object. This extension is still marked as experimental though.

Another variant is to use the direct Oracle extension, which will only work with Oracle and no other DBMS. While this may offer you more oracle native features, you will find a lot less information following this way.

With the PDO extension the following should work:

<?php
$db_username = "youusername";
$db_password = "yourpassword";
$db = "oci:dbname=yoursid";

$conn = new PDO($db,$db_username,$db_password);
// Another way to connect which might work
// $conn = new PDO('oci:dbname=//localhost:1521/mydb', $db_username, $db_password);

$st = $conn->prepare('UPDATE MANCITY SET USERNAME=? WHERE USERNAME=? AND EMAIL=?');
$st->execute(array("JOHN", "JON", "[email protected]"));
Sign up to request clarification or add additional context in comments.

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.