PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 7th, 1999, 11:44 PM
newmediaarts
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The following source code manages to reliably return the wrong information. Instead of returning the proper number it returns the number 3 for the value of $PID. Just so you know the value of objective_a is unique in each mysql row. PID is generated by MySQL as soon as the row is created.

<?
/* declare some relevant variables */
$hostname = "localhost";
$username = "root";
$password = "";
$dbname = "Schools";
/* make connection to database */
MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database");

@mysql_select_db("$dbname") or die("Unable to select database");
$date=(date("Y-m-d"));
$datadump = "INSERT INTO proposal VALUES('$student_name','$student_email','$student_grade','$state','$school','$district','$partner_te acher','$partner_teacher_email','$geny_t eacher','$geny_teacher_email','$project_name','$project_subject_area','$url','$objectives_a','$objec tives_b','$objectives_c','$require_hardw are','$require_software','$require_other','$ealr1a','$ealr1b','$ealr1c','$ealr2a','$ealr2b','$ealr2c ','$ealr3a','$ealr3b','$ealr3c','$proced ures','$assessment','$consultmsg','$draft','$feedback','$edit','$date','')";
MYSQL_QUERY($datadump);
MYSQL_CLOSE();


MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database");
@mysql_select_db("$dbname") or die("Unable to select database");


$select = "SELECT PID FROM proposal WHERE (objectives_a='$objectives_a');";
$result = MYSQL_QUERY($select);
$PID = $result;

include("thanks.html");
PRINT"$result -- result";
PRINT"<BR>Proposal ID number is $PID.<BR>";
PRINT"<BR>Proposal ID SELECT is $select.<BR>";
include("thanks2.html");
MYSQL_CLOSE();
?>

If anyone has suggestions as to a better way to return the PID of the file created in the first mysql query I would be open to any ideas.

Thanks.

------------------
Luke Bowerman
new media arts
www.judebowerman.com/nma


[This message has been edited by newmediaarts (edited 08-07-99).]

Reply With Quote
  #2  
Old August 8th, 1999, 08:09 PM
ros87
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I'm no php3 wizard but as far as I now $result is only a identifier and must be used with mysql_result to actually retrieve data from the query.

In onther words .. use

$PID = mysql_result($result,0,"PID");

-Roger

[This message has been edited by ros87 (edited 08-08-99).]

Reply With Quote
  #3  
Old August 8th, 1999, 10:53 PM
newmediaarts
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thank you very much. That worked great.

------------------
Luke Bowerman
new media arts
http://www.judebowerman.com/nma

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > MySQL Query Insanity


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT