I can't get any manuipulation of my mysql database online

Codes here !

Moderators: macek, egami, gesf

Mh_0
New php-forum User
New php-forum User
Posts: 11
Joined: Thu Nov 14, 2002 7:13 am
Location: UK
Contact:

I can't get any manuipulation of my mysql database online

Postby Mh_0 » Thu Nov 14, 2002 7:34 am

I hope someone out there can help me (being a newbie)
I am writing what is probably quite a simple website using mainly php, I have sorted being able to read all the information from the various databases, but I can't seem to get any form of manipulation to work,
below is a cut down version my manipulation code, has anyone got any ideas?

Code: Select all

<?
 if ($savecruise) {
 
   $db = mysql_connect("localhost", "root", "homer");
   mysql_select_db("Cruises",$db);
 
 $sql = "UPDATE general SET Cruisenum=$cruisenum,PI=$pi,Institute=$institute,Location=$location, sailingport=$sailingport,completion=$completion, year=$year WHERE general.Cruisenum=$cruisenum";

 $result = mysql_query($sql);

  echo "Cruise Information Updated.\n";

 $cruisepage = $cruisenum;
 };
?>
    <?
 if ($deletebutton) {
 
    $db = mysql_connect("localhost", "root", "homer");

    mysql_select_db("Cruises",$db);
 
    $sql = "DELETE FROM general WHERE Cruisenum=$cruisenum";   

    $result = mysql_query($sql);

    echo "$sql Record deleted!";
 
 };
?>
    <?
  if ($newbutton) {
 
  $db = mysql_connect("localhost", "root", "homer");

  mysql_select_db("Cruises",$db);

  $sql = "INSERT INTO general (Cruisenum,PI,Institute,Location) VALUES ('$cruisenum','$pi','$institute','$location')";

  $result = mysql_query($sql);

  echo "New Cruise Entered\n";
};
?>

Thanks in advance

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Thu Nov 14, 2002 10:07 am

ALTER
CREATE
DESCRIBE
DROP
GRANT
LOAD
SET
SHOW

documents here

way can be easy... use phpMyAdmin =) web-based mysql data base manager... =)

Mh_0
New php-forum User
New php-forum User
Posts: 11
Joined: Thu Nov 14, 2002 7:13 am
Location: UK
Contact:

Postby Mh_0 » Fri Nov 15, 2002 12:51 am

Ummmm I can't use phpmyadmin in its release format, I need to do it in the webpage because there are lots of tables that need to be altered at once, and the users need to be able to modify data rather than the webmaster

DutchBen
New php-forum User
New php-forum User
Posts: 36
Joined: Thu Oct 24, 2002 10:28 am
Location: Amsterdam

Re: I can't get any manuipulation of my mysql database onlin

Postby DutchBen » Fri Nov 15, 2002 11:19 am

Mh_0 wrote:
$db = mysql_connect("localhost", "root", "homer");
mysql_select_db("Cruises",$db);

$sql = "UPDATE general SET Cruisenum=$cruisenum,PI=$pi,Institute=$institute,Location=$location, sailingport=$sailingport,completion=$completion, year=$year WHERE general.Cruisenum=$cruisenum";

$result = mysql_query($sql);



I can't see any major fault in your code here, but a few hints. Take your connection code out of the if branches and put it in the top of your script, and possibly in an include file you can use in multiple pages.
Its important to use quotes, so Institute='$institute' instead of Institute=$institute. The query will fail if you don't.
If these things don't help you'll have to be more specific as to what is actually not working.

!! You can use phpMyAdmin to test your querys against your database !!

Mh_0
New php-forum User
New php-forum User
Posts: 11
Joined: Thu Nov 14, 2002 7:13 am
Location: UK
Contact:

Postby Mh_0 » Wed Nov 20, 2002 1:27 am

Its sorted, it was sorted by putting `s around the field names and 's around the variables

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Wed Nov 20, 2002 3:02 am



Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 0 guests