Reputation: 850 Master
- Active Posts:
- 1,821 (0.69 per day)
- 30-January 09
- Profile Views:
- Last Active:
- Today, 09:13 PM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
- Expert In:
Posts I've Made
Posted 2 May 2016You should be treating it as a string anyway... how is it getting into the system as an integer with a leading zero? Not from a database or a form field, it would come in as string from those. And surely you're not explicitly declaring it in your code if it's an account type number.
Posted 2 May 2016It's an octal number. Octal numbers are represented in the format 0nnn..., where nnn... is the number. As per the manual:
Prior to PHP 7, if an invalid digit was given in an octal integer (i.e. 8 or 9), the rest of the number was ignored. Since PHP 7, a parse error is emitted.
So, your number is being ignored once it hits the 9. 1011 from octal to decimal is 521.
Posted 12 Apr 2016I am unable to use your query though, it tries to look for a match on every row. The DocId is an integer and the ButtonLink is either a matching integer or a file path. When it tries to compare the two it breaks the query. I may add another field to the table to store the foreign key of the document and keep them separate.
It's best to store data types separately, so I would suggest moving the document ID to it's own nullable column. You can JOIN on integer to varchar, you just have to cast the integer to varchar, but as I said it would be best to keep integer data in an integer field and then foreign key constrain it
Posted 11 Apr 2016Well, your SQL is pretty messy and not really doing what you want by the looks. Assuming the join between Machine_Links and QCBD_Files does not generate duplicate rows, you're probably after something like this:
SELECT Machine_Links.Button_Id, Machine_Links.Machine_Id, Machine_Links.Button_Position, Machine_Links.Button_Name, Machine_Links.Button_Type, Machine_Links.Button_Link, CASE WHEN Machine_Links.Button_Type = 'QCBD_Link' THEN QCBD_Files.Doc_Name ELSE Machine_Links.Button_Link END AS Link_Text FROM Machine_Links LEFT OUTER JOIN QCBD_Files ON QCBD_Files.Doc_Id=Machine_Links.Button_Link WHERE Machine_Links.Machine_Id = 6
Note that the tables are not separated by a comma. Separating with a comma is SQL-89 standard, and you run into major problem with cartesian products when missing JOIN predicates (like you are). The SQL-92 standard, where you use LEFT OUTER JOIN / RIGHT OUTER JOIN / INNER JOIN / CROSS JOIN and FULL JOIN forces predicates, so is better to use and more current (I'll let you google that).
Notice that I have made a LEFT OUTER JOIN from Machine_Links to QCBD_Files. This means that every row of Machine_Links will be returned, and if a row exists in QCBD_Files where QCBD_Files.Doc_Id=Machine_Links.Button_Link, then we'll get that information as well. Since it is LEFT OUTER JOIN, if QCBD_Files does not have a corresponding row, the row from Machine_Links will still be returned, but all the values for QCBD_Files for that row will be NULL. Also something to keep in mind is if there are multiple rows in QCBD_Files where QCBD_Files.Doc_Id=Machine_Links.Button_Link then multiple (potentially duplicate) rows will be returned in the query. I'm not sure how your database is structured, otherwise I could offer some help there. See how you go, that query may well fix your issue. Also, I would highly recommend doing some online study of basic SQL syntax to brush up your skills. Any tutorial that has text such as FROM table1, table2, ..., close that window straight away, they are trying to poison your brain with bad information />
Posted 10 Apr 2016So it was removed just a few months ago? Since PHP7 was only just released in December.
It only reasserts to me that PHP is still the hellscape it was the last time I used it. Bloated, quarky, "easy to learn - easy to break".
Hey, let's keep the punches above the belt, there's no need to accuse PHP of being a theoretical particle.
- Member Title:
- = -1
- 41 years old
- June 24, 1974
- Years Programming:
- Programming Languages:
- HTML, XML, jQuery, PHP, SQL, MySQL, VBA, VBScript, PostgreSQL, C#, SSRS, SSIS, Crystal, BIML, Java
- Website URL: