Fatal error: Unsupported operand

Can anybody tell me why the following code does not work and gives an error message

/* Macro sc_lookup */
sc_lookup(bal_stk, "SELECT UnitsInStock FROM products
WHERE ProductID = ‘{ProductID}’
");

Error Message
mysql): SELECT UnitsInStock FROM products WHERE ProductID = ‘2’

Fatal error: Unsupported operand types in C:Program Files
etmakev5wwwrootscriptcaseappecogazform_ro_gplform_ro_gpl_apl.php on line 3649

Re: Fatal error: Unsupported operand

Try:

sc_lookup(bal_stk, 'SELECT UnitsInStock FROM products
WHERE ProductID = '.{ProductID};

If it where a string, then:

sc_lookup(bal_stk, ‘SELECT UnitsInStock FROM products
WHERE ProductID = "’.{ProductID}.’"’;

Re: Fatal error: Unsupported operand

The code above is not working it produces the wrong results
mysql): SELECT UnitsInStock FROM products WHERE ProductID = ‘. 4’

Why use the periode ?

Please Scott try to write the code complete for me

Re: Fatal error: Unsupported operand

I see I pasted your code with the double quotes and then completed the line with single.

I usually do something like:


$sql = 'SELECT UnitsInStock';
$sql .= ' FROM products';
$sql .= ' WHERE ProductID = '.{ProductID}; 

// displays: SELECT UnitsInStock FROM products WHERE ProductID = 2 
// yours: SELECT UnitsInStock FROM products WHERE ProductID = '2' 

or strings:
$sql .= ' WHERE string_field = "'.{string_value}.'"';

// displays: SELECT UnitsInStock FROM products WHERE string_field = "mystring"

sc_lookup(product_data,$sql);

As for the periods, I just like to denote my variables from strings (old habit)

If the error persists, can you echo the SQL to the screen then paste it into your DB manager … does it run?

Regards,
Scott.

Re: Fatal error: Unsupported operand

I believe the problem is that ProductID is a numeric value.

SELECT FROM products WHERE ProductID UnitsInStock = '2 ’

can not work out then, since '2 'here, not the number 2 but the string ‘2’ is.

The query
SELECT FROM products UnitsInStock WHERE ProductID = 2;

Should work out the query.
Also in SC:
/ * Macro sc_lookup * /
sc_lookup (bal_stk, "SELECT FROM products UnitsInStock
WHERE ProductID = {ProductID}
");

Re: Fatal error: Unsupported operand

I believe the problem is that ProductID is a numeric value.
SELECT FROM products WHERE ProductID UnitsInStock = ‘2’

Correct.

If you use phpMyAdmin, it allows you use ‘2’ in the statement, as I believe it may convert it for you. SC just sends it as is … giving you the error.

Regards,
Scott.

Re: Fatal error: Unsupported operand

That was my first choice before I posted for help in the forum
ProductID is a numeric field


(mysql): SELECT UnitsInStock FROM products WHERE ProductID = 2

Fatal error: Unsupported operand types in C:Program Files
etmakev5

I do not understand why it is so difficult to assign a value to a variable from a field name in the database

I do not understand why it works fine for
/* Macro sc_exec_sql */

sc_exec_sql("
UPDATE
products
SET
UnitsInStock = {NbrGalDisponible}
WHERE
ProductID = {ProductID}
");

What type of code you guys use to pickup data from a field and use that data for further processing?

Re: Fatal error: Unsupported operand

[quote author=ScottMartin link=topic=1517.msg4730#msg4730 date=1274304174]

I usually do something like:


$sql = 'SELECT UnitsInStock';
$sql .= ' FROM products';
$sql .= ' WHERE ProductID = '.{ProductID}; 

sc_lookup(product_data,$sql);

/quote]

The above code works better but I still have error message

Transactions not supported in ‘mysql’ driver. Use ‘mysqlt’ or ‘mysqli’ driver

(mysql): INSERT INTO ro_gpl (ProductID, DateRapGpl, PercentDisponible, NbrGalDisponible, EmployeeID, BalanceStockVirtuel, PerteGal) VALUES (1, ‘2010-05-20’, 0, 18000.00, 0, 0, 0)


(mysql): select last_insert_id()


(mysql): SELECT ProductID, ProductName FROM products ORDER BY ProductName

Re: Fatal error: Unsupported operand

Transactions not supported in ‘mysql’ driver. Use ‘mysqlt’ or ‘mysqli’ driver

-Load your project and select ‘Database Connections’ in the tree on your left.
-Select your main mysql connection and change DBMS Type to ‘MySQL (Transactions)’

Regards,
Scott.

Re: Fatal error: Unsupported operand

What is the difference Scott?
I would like to know
SC seems easy but One need programming expertize in PHP for sure… to write complete application.

Re: Fatal error: Unsupported operand

You would most likely get better information from searching online than from my few comment.

http://lmgtfy.com/?q=mysql+mysqli+difference

As far as PHP, I consider SC5 a foundation to get started … the more you know about that language itself, the better.

Regards,
Scott.

Re: Fatal error: Unsupported operand

Ok I try it:
In MySQL, there are different table types (InnoDB, MyISAM) ect. Depending on which table is selected, the table and thus the different database options. The databases of the major suppliers all working with transactions. This means that einern on write operations to database table (and thus ultimately also to the data file) before the start, the table must be locked (MySQL Lock Table …). Otherwise, simultaneous write operations from different users would hinder each other.
Transaction secure databases to organize against it, the result itself either to each write a Commit (autocommit) or by the developer can set for major changes to the databases of critical operations begin even before a marker and then with a rollback return there. Almost as if nothing had happened.

So if you are using MySQL InnoDB tables, then you need a driver supports the transaction security. Otherwise not. Then you have to worry even for Lock and Unlock.

I have learned to Oracle databases, so I always prefer secure transaction databases. Is less complicated at the end …

Re: Fatal error: Unsupported operand

In other words if I want to create a Multi-User Multi-Tasking application I better use MySql Transaction type option instead?

Re: Fatal error: Unsupported operand

You could say not so. If a multiuser / multitasking application is to be developed, then the developer must ensure that it is no conflict between read and write accesses.
The ACID - concept provides only here that does not come into direct conflict. The treatment of any conflicts is left to the developer but not spared. I think that is the use of write locks at the table level by the developers is a useful step. You solve the problem of timeliness of data. Especially with larger operations to read data, it can happen, yes, someone is reading this data eebenfalls and changes. When you restore the data, it is then inevitably lead to problems.
At best, googel mal “ACID” or reads at times to wikipedia. There are some useful links to problems with database systems.