i am working on a small projects, and need some help.
i was wondering if anybody could help me with this.
fee months ago i installed php and mySQL server on xp sp2.
i have script that workd perfcly on remote server, but when i work with it on lolcal server i got problems.
i will post my script first:
<?
//connection to server
include ( "../include/include.php");
if (!mysql_connect($host , $user, $pass)) {
print 'Could not connect to mysql';
exit;
}
mysql_select_db("$dbname");
$sel = mysql_query("SELECT * from currency");
//action add new currency
if ($action == "add")
{
$ad = mysql_query("INSERT INTO currency (currency_name, symbol, value) values ('" . $currency_name . "', '" . $symbol ."', '" . $rate . "')");
mysql_query($ad);
}
//action delete currency
if ($action == "delete")
{
$del = mysql_query("DELETE FROM currency WHERE currency_id = '" . $id . "'");
mysql_query($del);
}
//action edit currency
if ($action == "edit")
{
$sel_edit = mysql_query("SELECT * from currency where currency_id = '" . $id . "'");
mysql_query($sel_edit);
$row_edit = mysql_fetch_array($sel_edit);
}
//action update currency
if ($action == "update")
{
$upd = mysql_query("UPDATE currency SET currency_name = '" . $currency_name . "', symbol ='" . $symbol . "', value = '" . $rate . "' WHERE currency_id = '" . $id . "'");
mysql_query($upd);
}
$sel = mysql_query("SELECT * from currency");
$row = mysql_fetch_array($sel);
?>
if i do curency.php?action=edit&id=1
in my form i dont see values from mySql table.
here is how the code looks:
<? if ($action == "edit") {?>
<form name="form1" method="post" action="curency.php?action=update&id=<? echo $id?>">
<? } else { ?>
<form name="form1" method="post" action="curency.php?action=add">
<? } ?>
<table width="400" border="0" align="center" class="texttabelrosu">
<? if ($action == "add" or $action == "update") { ?>
<tr bgcolor="#FF0000" class="texttabel">
<td height="19" colspan="2">
<div align="center"><strong><font color="#FFFFFF"><?php echo $lang[valutapromjena]; ?>
!</font></strong></div></td>
</tr>
<? } ?>
<tr bgcolor="#240288" class="texttabel">
<td height="19" colspan="2">
<div align="center"><strong><font color="#FFFFFF">
<? if ($action <> "edit") {?>
<?php echo $lang[dodajvalutu]; ?>
<? } else { ?>
<?php echo $lang[promjenavalute]; ?>
<? } ?>
</font></strong></div></td>
</tr>
<tr class="texttabel">
<td height="19"> </td>
<td> </td>
</tr>
<tr class="texttabel">
<td width="47%" height="19"> <div align="right"><strong><?php echo $lang[nazivvalute]; ?>:</strong></div></td>
<td width="53%"><input name="currency_name" type="text" class="texttabel" id="currency_name" value="<? if ($action == "edit") { echo $row_edit[currency_name]; } ?>" size="30">
</td>
</tr>
<tr class="texttabel">
<td><div align="right"><strong> <?php echo $lang[svaluta]; ?>: </strong></div></td>
<td><input name="symbol" type="text" class="texttabel" id="symbol" value="<? if ($action == "edit") { echo $row_edit[3]; } ?>" size="15"></td>
</tr>
<tr class="texttabel">
<td><div align="right"><strong><?php echo $lang[obracunstopa]; ?>:</strong></div></td>
<td><input name="rate" type="text" class="texttabel" id="rate" value="<? if ($action == "edit") { echo $row_edit[4]; } ?>" size="15"></td>
</tr>
<tr class="texttabel">
<td> </td>
<td> </td>
</tr>
<tr class="texttabel">
<td> <div align="right">
<input name="image" type="image" title=" Update " src="img/button_update.gif" alt="Update" width="65" height="22" border="0">
</div></td>
<td><a href="index.php"> <img src="img/button_cancel.gif" width="65" height="22" border="0" title=" Cancel "></a></td>
</tr>
</table>
</form>
Tried so many things but it wont work !
Could somebody teach me on this.
Thank you very much