1.11M Members

stock

 
0
 

Hello,

I am trying to create a stock recording system:

<h4>STOCK RECORDING SYSTEM</h4>

<form action="action.php" method="post">

<table border="0" width="200">
<tr>
    <tr>
        <td>Produk  :</td><br>
        <td><input type="text" size="12" maxlength="22" name="Produk"></td>    
    </tr>    
    <tr>
        <td>Jumlah  :</td>
        <td><input type="text" size="12" maxlength="22" name="Jumlah"></td><br> 
    <tr>
        <td>Tanggal :</td>
        <td><input type="text" size="12" maxlength="22" name="Tanggal"></td><br>
    </tr>    
</table>


</form>

<?php

username='root';
password='';

$con = mysql_connect(localhost, username, password);
mysql_select_db("snack", $con);

mysql_query("INSERT INTO Produk VALUES ('Produk')");
mysql_query("INSERT INTO Jumlah VALUES ('Jumlah')");
mysql_query("INSERT INTO Tanggal_Masuk VALUES ('Tanggal_Masuk')");


?>




Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\Innovation\script_shop\stock.php on line 27
Line27:    username='root';

the username is correct.  Why the error still appears?
 
0
 

You are missing the $ sign in front of the variable name, change it to $username, bye!

 
0
 

The same goes for the password variable.

 
0
 

I am having problem on the combo box.

I have one database : snack
two tables: po and stock

po: po
stock: produk, jumlah, tanggal_masuk

<?php

$username='root';
$password='';

$con = mysql_connect('localhost', $username, $password);
mysql_select_db('snack', $con);

mysql_query("INSERT INTO Produk VALUES ('Produk')");
mysql_query("INSERT INTO Jumlah VALUES ('Jumlah')");
mysql_query("INSERT INTO Tanggal_Masuk VALUES ('Tanggal_Masuk')");

// combo box

    <select name="batch" onchange="submit();">
    <option value="-1" >-- Select Adress --</option>
    <?php

    $result = mysql_query('SELECT * FROM PO ORDER BY PO ASC') or die(mysql_error());
    while ($item = mysql_fetch_assoc($result))
    {
    echo '<option value="'.$item['po'].'" '.isSelected($item['po'],$batch).'>'.$item['namn'].'</option>';
    }
    ?>
    </select>


?>

I am trying to fill in po with produk type to list all the available products in the combo box.

Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\Innovation\script_shop\stock.php on line 39

line 39: <select name="batch" onchange="submit();">

 
0
 

Check your opening and closing php tags. You have one missing.
You should re-write this code referring to a good reference manual as
you are doing it.

 
0
 

As TonyG said put a closing php tag on line 14 in above code.

 
0
 

Getting close.

I wonder why I do not see the list of products appears in the combo box. I only see // combo box --select address--

 
0
 

Probably you get an empty set from this query:

SELECT * FROM PO ORDER BY PO ASC

Try it from a mysql client.

 
0
 

I wonder why I get empty set - it should works from localhost mysql

 
0
 

As cereal said run the query:

SELECT * FROM PO ORDER BY PO ASC

in phpmyadmin (or mysql client) and see if you get the correct resultset for options in your select. If the query returns correct result then check the html code (in Firefox right click -> View page source) and check whether there are no html errors also.

You might want to check whether isSelected($item['po'],$batch) function returns correct value.

 
0
 
$result = mysql_query('SELECT * FROM PO ORDER BY PO ASC') or die(mysql_error());
    echo $result;

it doesn't print out anything

 
0
 

If I view - page source in IE:

// combo box

    <select name="batch" onchange="submit();">
    <option value="-1" >-- Select Adress --</option>
    Resource id #4<br />
<b>Notice</b>:  Undefined index: po in <b>C:\xampp\htdocs\Innovation\script_shop\stock.php</b> on line <b>48</b><br />
<br />
<b>Fatal error</b>:  Call to undefined function isSelected() in <b>C:\xampp\htdocs\Innovation\script_shop\stock.php</b> on line <b>48</b><br />
 
0
 

<b>Fatal error</b>: Call to undefined function isSelected() in <b>C:\xampp\htdocs\Innovation\script_shop\stock.php</b> on line <b>48</b><br />

This is probably the answer: the isSelected() function that you are calling, does not exist. Have you included appropriate file where the function should be defined?

And also

Undefined index: po in <b>C:\xampp\htdocs\Innovation\script_shop\stock.php

means that there are no records since nothing exists in the $item array.

 
0
 

You should temporary remove the isSelected($item['po'],$batch) function and see if you get anything:

while ($item = mysql_fetch_assoc($result))
{
    echo '<option value="'.$item['po'].'" . $item['namn'] . '</option>';
}

The isSelected() function probably only adds selected="selected" to selected option.

 
0
 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\Innovation\script_shop\stock.php on line 71

that would be line 3.

 
0
 

Sory it should be:

echo '<option value="'.$item['po'].'">' . $item['namn'] . '</option>';

My error when copying.

 
0
 

The combo box remains empty

 
0
 

This is tricky.

What you get when you run this query in phpmyadmin:

SELECT * FROM PO ORDER BY PO ASC
 
0
 

I must first select the database then enter the query: this appears:

BBQ Snack
Metalik
Rendang
Stik BBQ
Stik biru

 
0
 

This is mysterious. The code in the snippet you posted seem to be OK (once corrected with suggestions from other posts). Can you post the whole code? I would have to test it in my environment to try to find something.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: