 |
|
|
06-23-2005, 03:36 PM
|
Update Database problem
|
Posts: 5,489
Name: Kandi
Location: Western NY
|
Okay, I'm almost done with the site...no errors, but for some reason it isn't updating the database. Can anyone spot why? I would appreciate any help you can give me!!
PHP Code:
<?
include("misc.inc");
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
$sql = "UPDATE Jobs SET Specialty = '$Specialty', State = '$State', Date = '$Date', Description = '$Description',
Facility = '$Facility', Practice_Type = '$Practice_Type', Call = '$Call', WHERE id = '$id' LIMIT 1";
Thanks!
|
|
|
|
06-23-2005, 08:07 PM
|
|
Posts: 174
Location: Nigeria/Lagos
|
Wat is ur misic.inc ?
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.
Please login or register to view this content. Registration is FREE
|
|
|
|
06-23-2005, 08:40 PM
|
|
Posts: 2,099
Name: Adam
Location: Colchester CT
|
Your setting $sql to be an UPDATE statement, but I don't see where you actually execute the statement against the database.
Your missing:
$result = mysql_query($sql);
|
|
|
|
06-24-2005, 03:04 PM
|
|
Posts: 5,489
Name: Kandi
Location: Western NY
|
misc.inc is the database login info.
I added the execute statement (which I don't know why I didn't catch in the first place)....it's still not updating.
I know my login is working and the variable are being set because I also have it set up to email me the updates and I'm getting all the info in the email....it's just not going into the database.
|
|
|
|
06-24-2005, 06:19 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
There's nothing out of place in the snippet you've posted; except I wouldn't wrap the $id value in '' since it's an integer yes?
Have you had this script run will all errors reporting yet? It would also be handy to see the entire script, not just the snippet...
|
|
|
|
06-24-2005, 08:43 PM
|
|
Posts: 4
|
PHP Code:
<?php
include_once("misc.inc");
mysql_connect($host,$user,$password)or die("Couldn't connect to server");
mysql_select_db($database)or die ("Couldn't select database");
mysql_query("UPDATE `Jobs`
SET
Specialty = '".$Specialty."',
State = '".$State."',
Date = '".$Date."',
Description = '".$Description."',
Facility = '".$Facility."',
Practice_Type = '".$Practice_Type."',
Call = '".$Call."'
WHERE
id = '".$id."'")or die(mysql_error());
?>
Last edited by Enrico; 06-24-2005 at 08:47 PM..
Reason: Forgot the PHP Tag.
|
|
|
|
06-25-2005, 11:40 AM
|
|
Posts: 5,489
Name: Kandi
Location: Western NY
|
I'm not getting any errors, it's doing everything it's supposed to ---- except make the changes in the database.
Here is the full code for the page with the lastest suggested changes:
PHP Code:
<?
include("misc.inc");
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
$sql = ("UPDATE `Jobs`
SET
Specialty = '".$Specialty."',
State = '".$State."',
Date = '".$Date."',
Description = '".$Description."',
Facility = '".$Facility."',
Practice_Type = '".$Practice_Type."',
Call = '".$Call."'
Notes = '".$Notes."'
WHERE
id = '".$id."'")or die(mysql_error());
$result = mysql_query($sql);
$yourwebsite = 'http://www.Global-MedicalSearch.com';
$Contact=$_GET['Contact']; // Whats your name ?!
$subject="GMS website Ad - '$Specialty', '$State', '$Initials' ";
$recipient_email='RealEmailEdited';
$header = "From: '$Contact_Email' \r\n";
$header .= "MIME-Version: 1.0\r\n";
$content= "Dear Kandi,
$FirstName posted an edited ad for
Date: " . $_GET['Date'] . "
Specialty: " . $_GET['Specialty'] . "
State: " . $_GET['State'] . "
Description: " . $_GET['Description'] . "
Facility: " . $_GET['Facility'] . "
Location:" . $_GET['Location'] . "
Practice Type: " . $_GET['Practice_Type'] . "
Call: " . $_GET['Call'] . "
Notes: ".$_GET['Notes']."
";
mail($_GET[recipient_email], $subject, $content, $header);
mail($Contact_Email, $subject, $content, $header);
echo "<font color=00008B><align=center><b>Thank you $FirstName! Your ad has been succesfully updated. A notification has been sent to: $Contact_Email and $recipient_email.</b><p>\n";
echo "<center><a href='javascript:history.go(-2)'>Go back to Search Results</a><p>\n";
echo "<center><a href='Recruiters.php'><b>Search for more ads</b></a>\n";
?>
This is the email that I get from the code where I plugged in dummy info:
Dear Kandi,
Kandi posted an edited ad for
Date: 2113-02-99
Specialty: Pediatrics
State: SD
Description: body of ad, details, etc
Facility: Facility where opportunitity exists
Location:Eastern
Practice Type: Single Specialty Group
Call: Unknown
Notes: duh
The main priority for this code if for the employees' changes to be instantaneous.
Last edited by KML9870; 06-25-2005 at 11:43 AM..
|
|
|
|
06-25-2005, 05:13 PM
|
|
Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
|
Could you please try this:
Code:
$sql = ("UPDATE Jobs
SET
Specialty = '".$Specialty."',
State = '".$State."',
Date = '".$Date."',
Description = '".$Description."',
Facility = '".$Facility."',
Practice_Type = '".$Practice_Type."',
Call = '".$Call."'
Notes = '".$Notes."'
WHERE
id = ".$id;
$result = mysql_query($sql) or die(mysql_error());
$sqlDdone = mysql_affected_rows($result);
if($sqlDone == 0){
echo 'sql has failed to update';
}
Last edited by metho; 06-25-2005 at 05:18 PM..
|
|
|
|
06-28-2005, 12:33 PM
|
|
Posts: 5,489
Name: Kandi
Location: Western NY
|
Thanks everyone for you help. I found my problem----I had a comma just before WHERE. After I took that out, it works great!
|
|
|
|
|
« Reply to Update Database problem
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|