
AndyB
Staff Alumni-
Posts
5,465 -
Joined
-
Last visited
Never
Everything posted by AndyB
-
The syntax for your query ought to be SELECT from tablename ORDER by fieldname DESC LIMIT 25. If the value of $total happened to be 250, do you actually a database field named 250? I doubt it. And that's why you get an error.
-
OK, now to be helpful/constructive. Templates by the ton, including full CSS layouts, all free at http://www.oswd.org A zillion photo-images, also free, http://www.sxc.hu to use for a header
-
[SOLVED] Is it possible to base a function off of a value from MySQL DB?
AndyB replied to tfburges's topic in PHP Coding Help
SELECT DISTINCT fieldname from tablename ... -
Given that it uses a template, what do you expect us to critique? And the template is a dreadful piece of coding - a classic example of how not to. Table tag soup at its 'finest'.
-
[SOLVED] Is it possible to base a function off of a value from MySQL DB?
AndyB replied to tfburges's topic in PHP Coding Help
Yes, you can selectively search the database for a particular field have more than one possible value ... select ... where fieldname IN('abc','def','ghi') ... etc. Looking at your specific question, you have a system that appears to allow users to enter multiple variants of the same information. It would be a better solution to allow that sort of data entry ONLY through a drop-down so you can control the user input and avoid personal variants. -
var url = "create_object.php?g_model" + escape(g_model) + "?g_objName" + escape(g_objName); surely that should be var url = "create_object.php?g_model=" + escape(g_model) + "&g_objName=" + escape(g_objName);
-
UPDATE will normally update ALL records that match the WHERE condition. SO, if you have more than one record where the target field is 'empty' then all such records would update. If that's not what you want to do, you will need something unique in the WHERE clause to update a single record reliably. If your table happens to contain an auto-incremented record id for example ...
-
and are you running that script from http://localhost ?
-
[SOLVED] Stop my sum rounding down when multiplying
AndyB replied to emma57573's topic in PHP Coding Help
It's all in how you format the displayed values. These will point you in the right direction: http://ca.php.net/manual/en/function.number-format.php http://ca.php.net/manual/en/function.sprintf.php -
You need to provide a far better description than that. Did you get an error? Did you get a blank white screen? Did you try to display the actual query string and check it's what you thought it was going to be?
-
Leave it alone in the database - that format is the best. Change how it is displayed by your scripts after being retrieved from the database. The date() function allows all kinds of personal preference date formats.
-
Since you have already been given the solution in another near-identical thread, I'll close this one. For reference purposes, compliant browsers return the x y coordinates of WHERE the submit image was clicked, relative to the upper left corner. For a form method POST, and a submit button named banana, $_POST['banana_x'] and $_POST['banana_y'] will contain those values. $_POST['banana'] will have no value.
-
If Update_beer has been clicked then $_POST['button1_x'] will have a value. If Update_lemmonade has been clicked then $_POST['button2_x'] will have a value.
-
That's exactly how an 'image submit' is supposed to work. It's the same as image maps where you NEED to know the point that was clicked. For reference, the x and y coordinates are the pixel values of the point clicked measured form the top left corner of the image. The 'use this better' has zero application with a form submit image since wherever you click it the form submits. The 'use this better' is the entire application if you have an image map. Does that help?
-
Although we all like to think our queries are flawless, a little help from a useful error message never hurts while testing
-
Actually, I'd expect the error to be as a result of this: $nsql = "SELECT id, user, avatar, subject, date, news FROM news WHERE id = '".$_GET['id']."'"; $nres = mysql_query($csql) OR die(mysql_error()); Notice that you define $nsql as the querystring and then use $csql when you execute the query ... $csql has no value!!
-
change $result=mysql_query($sql); to $result=mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $sql); If the answer to your problem isn't then obvious, post the full error message.
-
generic question. generic answer query the database and select whatever order by random() limit 1. display results appropriately
-
I don't see the image. Either there's no such image on your server or the image is not where you (and your code) think it is.
-
It's a browser setting, not 'code' - http://support.microsoft.com/kb/296326
-
My crystal ball isn't working
-
I suppose you could start by looking at the generated page (view source in your browser) to see what style class is used for each of those categories and then finding the same class definition in the CSS file.
-
Your layout is broken with IE6 and broken with Firefox. CSS is valid, html is invalid.
-
Identical set-up, identical code, different result. No, that doesn't make sense. Take a closer look, and if you can't spot what's really happening, show us some code.
-
[SOLVED] Not sure why info is not INSERT into the db?
AndyB replied to Clinton's topic in PHP Coding Help
For future reference, use rational error message displays: Replace: $result = mysql_query("INSERT INTO '$tablename' (datecode, producttype, transactiondate, joblocation, jobnumber, signout, signin, outinby) VALUES ('$datecode', '$producttype', '$transactiondate', '$joblocation', '$jobnumber', '$signout', '$signin', '$outinby')"); with: $query = "INSERT INTO `$tablename` (datecode, producttype, transactiondate, joblocation, jobnumber, signout, signin, outinby) VALUES ('$datecode', '$producttype', '$transactiondate', '$joblocation', '$jobnumber', '$signout', '$signin', '$outinby')"; $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // show useful error