randydg Posted January 27, 2009 Share Posted January 27, 2009 SELECT notes.note from notes INNER JOIN notes on custid.notes OUTER JOIN customer.id where username='{$_SESSION['username']}'"); im messing something up in the above command here is what I need. There is a table called notes within are custid and note. The custid points to id in table customer. Im trying to update the field note in notes table. but inorder to do that you verify the username in id in table customer. the rest of the script is fine, I know for 100% its the select part because when i add an or die it dies. Thanks, Randy Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/ Share on other sites More sharing options...
DeanWhitehouse Posted January 27, 2009 Share Posted January 27, 2009 Try changing SELECT notes.note from notes INNER JOIN notes on custid.notes OUTER JOIN customer.id where username='{$_SESSION['username']}'"); to SELECT notes.note from notes INNER JOIN notes on custid.notes OUTER JOIN customer.id WHERE customer.username='".$_SESSION['username']."'"); Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748004 Share on other sites More sharing options...
randydg Posted January 28, 2009 Author Share Posted January 28, 2009 Try changing SELECT notes.note from notes INNER JOIN notes on custid.notes OUTER JOIN customer.id where username='{$_SESSION['username']}'"); to SELECT notes.note from notes INNER JOIN notes on custid.notes OUTER JOIN customer.id WHERE customer.username='".$_SESSION['username']."'"); Its still not working here is my whole script maybe it will help.(I know its on the select line because the select part dies. <?php session_start(); if(!(isset($_SESSION['username']))){ ?> <script language="JavaScript">window.open("index.php", "_self")</script><?php } include("config.php"); $query = ("SELECT notes.note from notes INNER JOIN notes on custid.notes OUTER JOIN customer.id WHERE customer.username='".$_SESSION['username']."'"); $result = @mssql_query($query) or die ('Die'); $row = mssql_fetch_array($result); ?> <table align="center" border="0"> <div align="center">title: <?php $_SESSION['username']; ?> <br /> </div> <tr></tr> <form method="post" action="x.php" onSubmit="return validateForm(edit);"> <tr><td class="text"><div align="center">Notes: </div></td><td><div align="center"> <input id="note" type="text" size="50" maxlength="50" name="note" value="<?php echo $row['note'] ?>"> </div></td></tr> <tr><td colspan="2" align="center"><div align="center"> <input type="Submit" value="Update" /> </div></td></tr> Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748733 Share on other sites More sharing options...
DeanWhitehouse Posted January 28, 2009 Share Posted January 28, 2009 change $result = @mssql_query($query) or die ('Die'); to $result = mssql_query($query) or die ('Died, ahh, here is why <br>'.mssql_error()); not 100% on the mssql error bit Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748742 Share on other sites More sharing options...
corbin Posted January 28, 2009 Share Posted January 28, 2009 change $result = @mssql_query($query) or die ('Die'); to $result = mssql_query($query) or die ('Died, ahh, here is why <br>'.mssql_error()); not 100% on the mssql error bit Unfortunately knowing what's wrong in a MSSQL query is not nearly as easy as MySQL. There is mssql_get_last_message, but I've heard it's unreliable. Anyway: SELECT notes.note from notes INNER JOIN notes on custid.notes OUTER JOIN customer.id WHERE customer.username='".$_SESSION['username']."' $_SESSION['username'] could be breaking the query, but most likely, it's this: FROM notes INNER JOIN notes on custid.notes OUTER JOIN customer.id You're joining a table on itself without using an alias. That might be valid if you're not selecting anything, but I doubt it is. Also, where did custid.notes come from? The custid table is never mentioned. Also, what is up with that outer join? Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748754 Share on other sites More sharing options...
bluesoul Posted January 28, 2009 Share Posted January 28, 2009 mssql_get_last_message() is no less reliable than mysql_error(). I've never had a problem with it. Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748763 Share on other sites More sharing options...
randydg Posted January 28, 2009 Author Share Posted January 28, 2009 custid is not a table is in notes table custid in notes table points to id in customer table. You're joining a table on itself without using an alias. That might be valid if you're not selecting anything, but I doubt it is. Also, where did custid.notes come from? The custid table is never mentioned. Also, what is up with that outer join? Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748766 Share on other sites More sharing options...
corbin Posted January 28, 2009 Share Posted January 28, 2009 mssql_get_last_message() is no less reliable than mysql_error(). I've never had a problem with it. I was thinking it was unreliable, but after reading the notes on the manual page, it only returns the last line. Would be fine for 99.99999999999% of the time though. custid is not a table is in notes table custid in notes table points to id in customer table. You're joining a table on itself without using an alias. That might be valid if you're not selecting anything, but I doubt it is. Also, where did custid.notes come from? The custid table is never mentioned. Also, what is up with that outer join? Naming in MSSQL when you have a database selected goes: .[column] (the brackets are optional, and if you're aimed for portability, discouraged. They're equivalent to ` in MySQL.) So, custid would be a table, not a column. What are your tables' schema, and what exactly are you trying to pull? Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748773 Share on other sites More sharing options...
bluesoul Posted January 28, 2009 Share Posted January 28, 2009 Yeah, it sounds weird but in practice it works the same when used with die() or exit(). Only if you're doing concurrent queries will you introduce the possibility of it not displaying correctly and if that's going on you should probably rethink your code. Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748779 Share on other sites More sharing options...
corbin Posted January 28, 2009 Share Posted January 28, 2009 A concurrent query isn't possible in PHP since it's single threaded x.x. Or do you mean something else? But yeah, I don't think I'll ever run into trouble with mssql_get_last_message. I guess I had just subconsciously changed the last line thing to unreliability in my head. lol. Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748781 Share on other sites More sharing options...
bluesoul Posted January 28, 2009 Share Posted January 28, 2009 I'm not braining very well today (I blame the weather), I meant consecutive queries. If you don't append or die(mssql_get_last_message()) you could probably miss that message. I read an article when I was first getting acclimated to MSSQL and it presented some really bizarre scenario that could make it not work. I don't have the link anymore but I don't think it's anything to fret over either, lol. Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-748784 Share on other sites More sharing options...
randydg Posted January 29, 2009 Author Share Posted January 29, 2009 so does this mean nobody knows how to fix the select command? I know its not far off cause I had one sorta like it and worked fine, (trying to find it) Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-749934 Share on other sites More sharing options...
randydg Posted February 2, 2009 Author Share Posted February 2, 2009 Ok now im getting the following error: Fatal error: Call to undefined function mssql_error() in notes.php on line 6 $sqlquery=("Select notes.note from notes INNER JOIN notes on notes.custid = customer.id where username='{$_SESSION['username']}'"); $result = @mssql_query($sqlquery) or die ('Error: '.mssql_error ()); Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-752807 Share on other sites More sharing options...
randydg Posted February 2, 2009 Author Share Posted February 2, 2009 I belive I have solved my problem here is the new line that doesnt return errors: $sqlquery=("Select * from notes INNER JOIN notes ON custid = customer ON id where username='{$_SESSION['username']}'"); Quote Link to comment https://forums.phpfreaks.com/topic/142703-mssql-select-error-php-script-help-please/#findComment-752944 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.