[56K WARN]sql UPDATE not working on localhost
Moderator: General Moderators
-
invisibled
- Forum Contributor
- Posts: 112
- Joined: Sun Apr 29, 2007 3:35 pm
- Location: New Westminster
[56K WARN]sql UPDATE not working on localhost
Hey everybody,
So I recently reinstalled my OS (OS X) and reinstalled php, mysql, phpmyadmin etc etc.
when i go to run update queries from php, it never works. My code is all right cause it works on my webserver, just not on my localhost.
i went into PHP myAdmin privliges and set all the users too ALL PRIVILEGES and still nothing.
could anybody throw some ideas out there as to why its doing this?
So I recently reinstalled my OS (OS X) and reinstalled php, mysql, phpmyadmin etc etc.
when i go to run update queries from php, it never works. My code is all right cause it works on my webserver, just not on my localhost.
i went into PHP myAdmin privliges and set all the users too ALL PRIVILEGES and still nothing.
could anybody throw some ideas out there as to why its doing this?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
also wouldn't hurt posting your phpmyadmin config
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
invisibled
- Forum Contributor
- Posts: 112
- Joined: Sun Apr 29, 2007 3:35 pm
- Location: New Westminster
reply
well there is no code is question or any error msg's so there is nothing to show for that.
here are the privileges for phpmyadmin.

here are the privileges for phpmyadmin.

Re: reply
...invisibled wrote:well there is no code is question or any error msg's so there is nothing to show for that.
here are the privileges for phpmyadmin.
This pic gives us 0 information, because you did not tell us what user you are using, and it most likely is a code problem.
So please if you want some help, give us some real information.
First thing I would do is
Code: Select all
error_reporting(E_ALL);Code: Select all
mysql_select_db('my_database') or die('Could not select database');
$result = mysql_query($query) or die('Query failed: <br>' . $query . '<br>' . mysql_error());-
invisibled
- Forum Contributor
- Posts: 112
- Joined: Sun Apr 29, 2007 3:35 pm
- Location: New Westminster
...
no
there is nothing wrong with my code. Im not sure why you think you know the situation better than me. the code is fine. there is nothing wrong with the code. read my original post, its an issue with my local host. and error reporting is on.
I am using the user invisibled
there is nothing wrong with my code. Im not sure why you think you know the situation better than me. the code is fine. there is nothing wrong with the code. read my original post, its an issue with my local host. and error reporting is on.
I am using the user invisibled
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: [56K WARN]sql UPDATE not working on localhost
Your web server and local host are two different machines, with two potentially different set ups. What works on one and not on the other suggests the code is is not compatible with your local environment. What are your local setting and your server settings? Run the following in a new file on each server and tell us the results please.invisibled wrote:when i go to run update queries from php, it never works. My code is all right cause it works on my webserver, just not on my localhost.
Code: Select all
<?php
$neg = array('off', 0, false, '', null);
$flags = array(
'Register Globals' => 'register_globals',
'Short Tags' => 'short_open_tag',
'Display Errors' => 'display_errors',
'Magic Quotes GPC' => 'magic_quotes_gpc',
'Magic Quotes Runtime' => 'magic_quotes_runtime',
'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";
$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
$le .= ' ' . implode(' ', array_slice($gle, $i, $wide)) . $eol;
}
$ec = array(
'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
$e2 = array();
foreach ($ec as $n => $v)
{
if (!in_array($n, $e) and $n != 'E_ALL')
{
$e2[] = $n;
}
}
$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
$er = $er . ' (' . implode(' | ', $e) . ')';
}
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}
echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;
if (!$cli)
{
echo '</pre></body></html>', $eol;
}
?>-
invisibled
- Forum Contributor
- Posts: 112
- Joined: Sun Apr 29, 2007 3:35 pm
- Location: New Westminster
results
ok i got the results for both servers, thats a nifty little code, thanks!
localhost
webserver
localhost
Code: Select all
PHP Version: 5.2.1
PHP OS: Darwin
Error Reporting: 6135 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: Off
Short Tags: Off
Display Errors: On
Magic Quotes GPC: Off
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: /usr/local/php5/lib/php.ini
Loaded Extensions:
zip xmlwriter libxml xmlrpc
dom xmlreader xml wddx
tokenizer session pcre SimpleXML
SPL PDO sockets soap
snmp SQLite standard Reflection
posix pdo_sqlite OpenBase Module memcache
mbstring ldap imap iconv
hash gd ftp filter
exif dbase date ctype
calendar bz2 bcmath zlib
openssl apache curl fbsql
gettext json mcrypt mhash
ming mssql mysql mysqli
oci8 odbc pdf pdo_mysql
PDO_OCI pdo_pgsql pgsql xslwebserver
Code: Select all
PHP Version: 5.2.2
PHP OS: Linux
Error Reporting: 6135 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: Off
Short Tags: On
Display Errors: On
Magic Quotes GPC: On
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: /home/14678/etc/php.ini
Loaded Extensions:
libxml xmlwriter xmlrpc xmlreader
xml wddx tokenizer session
SimpleXML SPL sockets soap
PDO standard Reflection pspell
posix pgsql pdo_sqlite pdo_pgsql
pdo_mysql SQLite mysqli mysql
mime_magic mhash mcrypt mbstring
ldap json imap iconv
hash gettext gd ftp
filter exif dom dba
date curl ctype calendar
bz2 bcmath zlib pcre
openssl xsl cgi-fcgi- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
invisibled
- Forum Contributor
- Posts: 112
- Joined: Sun Apr 29, 2007 3:35 pm
- Location: New Westminster
reply
feyd | Please use
and here is the update page
feyd | Please use
Code: Select all
,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]
ok here is my update functionCode: 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 FUNCTIONand here is the update page
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.php" 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
,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]Magic quotes are enabled on the web server, but not on your localhost. Echo your query & run it manually (through phpmyadmin or command line) - you might get some errors you aren't expecting. Look into get_magic_quotes_gpc().
Also, this line does absolutely nothing:
Also, this line does absolutely nothing:
Code: Select all
$client = str_replace( "'", "'", $client);Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
To add a little more to pickle's observation:
If you are not doing something with the raw post data, why are you using resource in assigning them to new vars? Then, you replace all "'" with "'", which does nothing but waste more resource.
Code: Select all
<?php
$updateID = $_POST["updateID"];
$client = $_POST["client"];
$projectNum = $_POST["projectNum"];
$owed = $_POST["owed"];
$paid = $_POST["paid"];
$contact = $_POST["contact"];
$client = str_replace( "'", "'", $client);
?>-
invisibled
- Forum Contributor
- Posts: 112
- Joined: Sun Apr 29, 2007 3:35 pm
- Location: New Westminster