Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Update Database problem
Old 06-23-2005, 03:36 PM Update Database problem
KML9870's Avatar
One Bad Mamma :-)

Posts: 5,489
Name: Kandi
Location: Western NY
Trades: 0
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!
KML9870 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-23-2005, 08:07 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
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
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 06-23-2005, 08:40 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
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);
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 06-24-2005, 03:04 PM
KML9870's Avatar
One Bad Mamma :-)

Posts: 5,489
Name: Kandi
Location: Western NY
Trades: 0
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.
KML9870 is offline
Reply With Quote
View Public Profile
 
Old 06-24-2005, 06:19 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
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...
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 06-24-2005, 08:43 PM
Junior Talker

Posts: 4
Trades: 0
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.
Enrico is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 11:40 AM
KML9870's Avatar
One Bad Mamma :-)

Posts: 5,489
Name: Kandi
Location: Western NY
Trades: 0
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..
KML9870 is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 05:13 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
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';

}
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.

Last edited by metho; 06-25-2005 at 05:18 PM..
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 06-28-2005, 12:33 PM
KML9870's Avatar
One Bad Mamma :-)

Posts: 5,489
Name: Kandi
Location: Western NY
Trades: 0
Thanks everyone for you help. I found my problem----I had a comma just before WHERE. After I took that out, it works great!
KML9870 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Update Database problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25174 seconds with 12 queries