Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can !
Moderator: General Moderators
invisibled
Forum Contributor
Posts: 112 Joined: Sun Apr 29, 2007 3:35 pm
Location: New Westminster
Post
by invisibled » Sun Aug 26, 2007 9:41 pm
Hey guys,
ok so mysql update queries are not working on my localhost and i need to figure out why and right now i am completly stuck. I know its not my code becuase, it works on my webserver and it NEVER works on any sites on my localhost.
Here are the versions of my software
Mac OS X 10.4.10
Php 5.2.2
Apache 1.3
MySql 5.0.37
I dont really know what else to say other than i'm completly stuck. If you need me to post somthing tell me and i'll post it.
Thanks to all in advance
-Shan
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 26, 2007 9:46 pm
Something tells me it actually is your code. Can you post some of it?
invisibled
Forum Contributor
Posts: 112 Joined: Sun Apr 29, 2007 3:35 pm
Location: New Westminster
Post
by invisibled » Sun Aug 26, 2007 10:06 pm
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
//UPDATE REORD FUNCTION
if (isset ($_POST["updateID"])):
$updateID = $_POST["updateID"];
$client = $_POST["client"];
$projectNum = $_POST["projectNum"];
$owed = $_POST["owed"];
$paid = $_POST["paid"];
$contact = $_POST["contact"];
$client = str_replace( "'", "'", $client);
$query = "UPDATE ida_financial SET client='$client', projectNum='$projectNum', owed='$owed', paid='$paid', contact='$contact' WHERE entryID='$updateID';";
$upd = mysql_query($query);
endif;
//UPDATE RECORD FUNCTION
and here the page with teh form
Code: Select all
/****************FINANCIAL EDIT PAGE************/
function financialEdit($go){
$updateID = $_GET["updateID"];
$query = "SELECT * FROM ida_financial WHERE entryID='$updateID';";
$sel = mysql_query($query) or die("$query failed");
if($res = mysql_fetch_array($sel)):
$client = $res["client"];
$projectNum = $res["projectNum"];
$owed = $res["owed"];
$paid = $res["paid"];
$contact = $res["contact"];
endif;
?>
<table>
<form action="../financial/" method="POST">
<td><input type="hidden" name="updateID" value="<?=$updateID?>" /></td></tr>
<tr><td align="right"> Client: </td><td> <input type="text" name="client" value="<?php print $client?>" /> </td></tr>
<tr><td align="right"> Record #: </td><td> <input type="text" name="projectNum" value="<?php print $projectNum?>" /> </td></tr>
<tr><td align="right"> Owed: </td><td> <input type="text" name="owed" value="<?php print $owed?>" /> </td></tr>
<tr><td align="right"> Paid: </td><td> <input type="text" name="paid" value="<?php print $paid?>" /> </td></tr>
<tr><td align="right"> Contact: </td><td> <input type="text" name="contact" value="<?php print $contact?>" /> </td></tr>
<tr><td align="right" colspan="2"> <input type="submit" name="update" value="Save" /> </td></tr>
</form>
</table>
<?php
}//END financialEdit($go)
/****************FINANCIAL EDIT PAGE************/
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Mon Aug 27, 2007 7:28 am
Hi
invisibled
You need to escape special chars in all you parameters.
F.e. $client = mysql_escape_string($client);
Also next string is very interesting, what it is doing ?
Code: Select all
$client = str_replace( "'", "'", $client);
invisibled
Forum Contributor
Posts: 112 Joined: Sun Apr 29, 2007 3:35 pm
Location: New Westminster
Post
by invisibled » Mon Aug 27, 2007 11:11 am
How will using escape string get my update queries working? That function reaplces a single quote with a hardcoded single quote, the forum just changes the ascii code into a single quote
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Mon Aug 27, 2007 11:14 am
Only one Update qeury don't work or all update queries don't work on the host ?
miro_igov
Forum Contributor
Posts: 485 Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria
Post
by miro_igov » Mon Aug 27, 2007 12:12 pm
Try
Code: Select all
$upd = mysql_query($query) or die(mysql_error());
This will show you if you have error in the query.
Also adding ini_set('display_errors',1); will help you if the script contains errors.
i never seen this if: endif; syntax in php, are you sure it is valid?
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Mon Aug 27, 2007 12:29 pm
miro_igov wrote: skipped
i never seen this if: endif; syntax in php, are you sure it is valid?
Yeah it is valid, it is best syntax to combine php and html together.
miro_igov
Forum Contributor
Posts: 485 Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria
Post
by miro_igov » Mon Aug 27, 2007 12:31 pm
I like if() { } because i can mark all the code between {} with my editor
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Mon Aug 27, 2007 1:45 pm
Are you sure you successfully connect to mysql?
Maybe you have not GRANT any users@localhost ...
My suggestion is that it is not a code mistake, but a mysql administration mistake ...
There are 10 types of people in this world, those who understand binary and those who don't