Jump to content

BrianM

Members
  • Posts

    217
  • Joined

  • Last visited

    Never

Everything posted by BrianM

  1. I think it's JavaScript that uses this on web pages. Does anyone know how this is done? If so, could you please provide an example? I can provide a more descriptive question if needed.
  2. Have you tried Google for any examples? That's typically the first thing I always do in a case like this.
  3. I've searched Google for subjects as "How to add php session id in url" and such, but hadn't had any luck with finding the answer I'm looking for. Could anyone please help by maybe showing an example of creating a session and adding the session id inside the url bar? Please and thank you!
  4. Does anyone know of a tutorial showing how this is done, or does anyone mind explaining?
  5. thorpe, thanks very much. You are right. It now works.
  6. Here is my code: <?php $result = mysql_query("SELECT Date FROM $table id=$id") or die(mysql_error()); ?> And here is the error I'm receiving: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '08-1111-E id=1' at line 1 Can anyone tell me what is wrong? Thanks
  7. Ah, thank you again for your help! Learn something new everyday.
  8. Unknown column '1' in 'where clause' - that's the error I get. That doesn't make since, I have an 'id' column. Here is what my table looks like at the moment to give you a visual. id date report 1 07-04-08 test report.
  9. Okay, a little problem ... can't figure this one out. Here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>MPS Project Tracking - by Brian Medley</title> </head> <?php mysql_connect('localhost', 'brian', 'some_pass') or die(mysql_error()); mysql_select_db('reports') or die(mysql_error()); $table = $_GET['table']; $id = $_GET['id']; $sql = mysql_query("SELECT * FROM `$table` WHERE id=`$id`"); while($row = mysql_fetch_array($sql)) { echo $row['date'] . " " . $row['report']; } ?> <body> </body> </html> And I get this error when I display the page: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\edit_report.php on line 16
  10. Yeah, I was going to say, while waiting I Googled this little example from w3schools.com SELECT * FROM person WHERE FirstName='Peter' Alright, well hopefully all will go well from here. Thank you very much for your help and the quick reply!
  11. Would somebody please show me an example of a database connection to MySQL via PHP selecting and displaying one row from a table and not every row in it? I'm wanting to select only one row from a table, selected by it's "id" and display only that one row. And the id will be pulled from a query string using $_GET['id'] and storing that as a variable at the top of the script; ie. "../index.php?table=some_table&id=1" - $id = $_GET['id'];
  12. something like <?php if ($GLOBALS['text_dir'] === 'rtl') { echo '*,'; } echo $GLOBALS['cfg']['NaviWidth']; if ($GLOBALS['text_dir'] === 'ltr') { echo ',*'; } ?>
  13. = == and === What is the difference between the single, double and triple equal signs, and is there anything higher than 3 used at once?
  14. How would I set the size of this text box using CSS? <td id="header_report">report</td> <style type="text/css"> #header_report { size: 100; } </style> That doesn't work...
  15. //Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating var int[64] r, k //r specifies the per-round shift amounts r[ 0..15] := {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22} r[16..31] := {5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20} r[32..47] := {4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23} r[48..63] := {6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21} //Use binary integer part of the sines of integers (Radians) as constants: for i from 0 to 63 k[i] := floor(abs(sin(i + 1)) × (2 pow 32)) //Initialize variables: var int h0 := 0x67452301 var int h1 := 0xEFCDAB89 var int h2 := 0x98BADCFE var int h3 := 0x10325476 //Pre-processing: append "1" bit to message append "0" bits until message length in bits ≡ 448 (mod 512) append bit (bit, not byte) length of unpadded message as 64-bit little-endian integer to message //Process the message in successive 512-bit chunks: for each 512-bit chunk of message break chunk into sixteen 32-bit little-endian words w[i], 0 ≤ i ≤ 15 //Initialize hash value for this chunk: var int a := h0 var int b := h1 var int c := h2 var int d := h3 //Main loop: for i from 0 to 63 if 0 ≤ i ≤ 15 then f := (b and c) or ((not b) and d) g := i else if 16 ≤ i ≤ 31 f := (d and b) or ((not d) and c) g := (5×i + 1) mod 16 else if 32 ≤ i ≤ 47 f := b xor c xor d g := (3×i + 5) mod 16 else if 48 ≤ i ≤ 63 f := c xor (b or (not d)) g := (7×i) mod 16 temp := d d := c c := b b := b + leftrotate((a + f + k[i] + w[g]) , r[i]) a := temp //Add this chunk's hash to result so far: h0 := h0 + a h1 := h1 + b h2 := h2 + c h3 := h3 + d var int digest := h0 append h1 append h2 append h3 //(expressed as little-endian)
  16. It worked perfectly! Thank you, hitman6003.
  17. I added an if statement suggesting that .. <?php if (!$array) { echo "error blah blah .."; } ?> But that still doesn't get rid of the automated PHP error output, is disabling display_errors the only way to get rid of this?
  18. I have a dynamic table written with PHP and Javascript, and if it doesn't return any rows from the table it gives this output as an error: Warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\view.php on line 21 Warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\view.php on line 76 Instead, I want to assign my own error output with an echo statement. How would I say replace the automatic error with my own echo statement errors? Here is my code for the page, and I've commented lines 21 and 76: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MPS Project Tracking - by Brian Medley</title> </head> <?php if(!isset($_GET['table'])) { die("You must have a table name set in the query string."); } $table = $_GET['table']; mysql_connect("localhost", "brian", ""); mysql_select_db("reports"); function returnheaders() { global $table; $sql = mysql_query("SELECT * FROM `$table` LIMIT 1") or die(mysql_error()); $array = mysql_fetch_array($sql); foreach($array as $key => $value) { // line 21 if(!is_numeric($key) && $key != "id") { echo("<td id=\"header_$key\">$key</td>\n"); } } } function returndata() { global $table; $sql = mysql_query("SELECT * FROM `$table`"); while($row = mysql_fetch_array($sql)) { echo("<tr id=\"dataset_row".$row['id']."\">\n"); foreach($row as $key => $value) { if(!is_numeric($key) && $key != "id") { echo("<td id=\"".$key.$row['id']."\" nowrap><a id=\"".$key."_".$row['id']."_value\" href=\"javascript:edit_row(".$row['id'].");\">".$value."</a></td>\n"); } } echo("</tr>\n"); } } function loaddynamicjava() { global $table; echo("<script type=\"text/javascript\">\nvar readylight = true;\nfunction edit_row(row) {\nvar currentval;\n"); $sql = mysql_query("SELECT * FROM `$table` WHERE id=1") or die(mysql_error()); $array = mysql_fetch_array($sql); foreach($array as $key => $value) { if(!is_numeric($key) && $key != "id") { echo("currentval = document.getElementById(\"".$key."_\"+row+\"_value\").innerHTML;\n"); echo("document.getElementById(\"".$key."\"+row).innerHTML = "); if($key == "date") echo("'<input type=\"button\" name=\"save\" value=\"Save\" onClick=\"savedata('+row+');\">"); else echo("'"); echo("<input type=\"text\" id=\"".$key."_'+row+'\" name=\"".$key."_'+row+'\" value=\"'+currentval+'\" />';\n"); } } echo("}\nfunction savedata(row) {\nif(!ready) { alert(\"Database is still saving other data!\"); return; }\nready = false;\nvar currentdata;"); foreach($array as $key => $value) if(!is_numeric($key)) if($key == "id") echo("document.getElementById(\"id\").value = row;\n"); else echo("document.getElementById(\"".$key."\").value = document.getElementById(\"".$key."_\"+row).value;\n"); echo("document.getElementById(\"theform\").submit();\n"); foreach($array as $key => $value) if(!is_numeric($key) && $key != "id") { echo("currentdata = document.getElementById(\"".$key."_\"+row).value;\n"); echo("document.getElementById(\"".$key."\"+row).innerHTML = '<a href=\"javascript:edit_row('+row+');\" id=\"".$key."_'+row+'_value\">'+currentdata+'</a>';\n"); } echo("}\nfunction nowready() { ready = true; }</script>"); } function returnformfields() { global $table; $sql = mysql_query("SELECT * FROM `$table` LIMIT 1"); $array = mysql_fetch_array($sql); foreach($array as $key => $value) // line 76 if(!is_numeric($key)) echo("<input type=\"hidden\" name=\"".$key."\" id=\"".$key."\" />\n"); echo("<input type=\"hidden\" name=\"table\" value=\"$table\" />\n"); } ?> <?php loaddynamicjava(); ?> <body> <table border="1" cellpadding="0" cellspacing="0"> <tr class="header"><?php returnheaders(); ?></tr> <?php returndata(); ?> </table> <form action="update.php" method="post" target="hiddenframe" name="theform" id="theform"> <?php returnformfields(); ?> </form> Go <a href="javascript:history.back();">back</a> a page. <iframe src="about:blank" style="display: none;" name="hiddenframe" id="hiddenframe" onLoad="nowready();">This page requires iFrames which your browser does not support.</iframe> </body> </html>
  19. Well I've fixed one problem, the query string is working fine with the form action now. But now I'm getting this error output by mysql_query() - Data truncated for column 'date' at row 1 - again on the same line, 22, with the data function on it. Any suggestions?
  20. I'm getting this error, all on line 22. Notice: Use of undefined constant m - assumed 'm' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\create.php on line 22 Notice: Use of undefined constant d - assumed 'd' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\create.php on line 22 Notice: Use of undefined constant y - assumed 'y' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\create.php on line 22 <?php if(!isset($_GET['table'])) { print('You must have a table name set in the query string.'); } $table = $_GET['table']; mysql_connect("localhost", "brian", ""); mysql_select_db("reports"); if (isset($_POST['report_create'])) { if (!$_POST['report']) { print('You must type in a report.'); } mysql_query("INSERT INTO `$table` (date, report) VALUES ('".date(m-d-y)."', '".$_POST['report']."')") or die(mysql_error()); // this is line 22 } ?> I've commented line 22 in the code. Can somebody please tell me what's wrong with my date() function?
  21. Actually, false alarm; no data inside the table But thank you for the quick reply.
  22. My table wont display anything but the headers. It isn't displaying output from the database... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>MPS - View Data</title> </head> <?php mysql_connect('localhost', 'brian', '') or die(mysql_error()); mysql_select_db('mps') or die(mysql_error()); if (isset($_COOKIE['username'])) { $username = $_COOKIE['username']; $password = $_COOKIE['password']; $check_one = mysql_query("SELECT * FROM mps_login WHERE username = '$username'") or die(mysql_error()); while($check_two = mysql_fetch_array($check_one)) { if ($password != $check_two['password']) { header('Location: login.php'); } else { ?> <body> <?php mysql_select_db('mps'); $result = mysql_query("SELECT * FROM mps_data"); ?> <table> <tr> <th>Client project number</th> <th>Client project name</th> <th>Client name</th> <th>Client address one</th> <th>Client address two</th> <th>Client office phone</th> <th>Client fax phone</th> <th>Client cell phone</th> <th>Client email</th> </tr> <?php while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['client_project_number'] . "</td>"; echo "<td>" . $row['client_project_name'] . "</td>"; echo "<td>" . $row['client_name'] . "</td>"; echo "<td>" . $row['client_address_one'] . "</td>"; echo "<td>" . $row['client_address_two'] . "</td>"; echo "<td>" . $row['client_office_phone'] . "</td>"; echo "<td>" . $row['client_fax_phone'] . "</td>"; echo "<td>" . $row['client_cell_phone'] . "</td>"; echo "<td>" . $row['client_email'] . "</td>"; echo "</tr>"; } ?> </table> </body> </html> <?php } } } else { header('Location: login.php'); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.