Jump to content

Dissonance

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

About Dissonance

  • Birthday 07/21/1982

Contact Methods

  • AIM
    Anesaru
  • Website URL
    http://

Profile Information

  • Gender
    Not Telling
  • Location
    Chicago, IL

Dissonance's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. For your inventory link, you wouldn\'t even need mod_rewrite. If /inventory/ is a top-level directory in your document root, you can just navigate to www.yoursite.com/inventory/ and Apache will load the index file automatically. You just need to tweak your code a bit. RewriteEngine On # Will send anyone asking for www.yoursite.com/whatever # (with or without trailing slash and regardless of case) to index.php?page=whatever # AS LONG AS \'whatever\' is not \'inventory\'. In theory, anyway. # I haven\'t tested this out yet. RewriteRule ^/([^inventory]+)/?$ index.php?page=$1 [NC] To learn how to use mod_rewrite, you should look up regular expressions. Once you get that down, the little brackats and carots will all make sense.
  2. Do you have register_globals on or off? If they\'re off, then you need to use the $_POST superglobal. [php:1:dd7aa15af7]<?php if (!$adv_name &amp;&amp; !$rec_date &amp;&amp; !$rec_status) { ?>[/php:1:dd7aa15af7] Would need to be changed to this: [php:1:dd7aa15af7]<?php if (empty( $_POST[\'adv_name\'] ) || empty( $_POST[\'rec_date\'] ) || empty( $_POST[\'rec_status\'] )) { ?>[/php:1:dd7aa15af7]
  3. I\'m having a bit of trouble understanding you, so correct me if I\'m wrong. You have an HTML form with a text field or text area. When you type a bunch of junk into it and submit the form, it dumps the contents of the text field or area into the database. When you retrieve the data from the database, however, everything appears as a one, very long line of text no matter how many times you edit it?
  4. Here you go. A working example on the house. [php:1:791ebc7cf4]<?php error_reporting ( E_ALL ); # Just a dummy value. $user_id = 100; if ( isset ( $_POST[\'submit\'] ) ) { # Begin the first part of the query. We\'ll manually specify # the id and user fields. $sql = \"INSERT INTO test1 ( id, user\"; # Create the fields to work with. for ( $i = 1; $i < count ( $_POST ) - 2; $i++ ) { $sql .= \", item$i \"; } # Create the insertion values. $sql .= \") VALUES ( \'\', \'$user_id\'\"; for ( $i = 1; $i < count ( $_POST ) -2; $i++ ) { $sql .= \", \'$item$i\'\"; } $sql .= \" )\";\"; # Echo out the query to see if it meets your approval. echo $sql; } else { # Just a sample form for you to mess with. Alter the $fields # variable to change the number of form fields rendered. # The number rendered will be $fields minus 1, so \'11\' will # output 10 fields. This does NOT include the id and user_id # fields. $fields = 11; echo \"<form method=\"post\" action=\"\" . $_SERVER[\'PHP_SELF\'] . \"\">n\"; for ( $i = 1; $i < $fields; $i++ ) { echo \"<p>$i <input type=\"text\" name=\"item$i\" /></p>n\"; } echo \"<input type=\"submit\" name=\"submit\" value=\"Submit\">n\"; echo \"</form>n\"; } ?>[/php:1:791ebc7cf4]
  5. [php:1:6ae32ffd94]$result = mysql_query ( \"SELECT $table1.field1, $table2.field2, $table2.field3 FROM $table1 INNER JOIN $table2 ON $table1.id = $table2.member_id\" ); if ( !$result ) { // Fail } else { $row = mysql_fetch_assoc ( $result ); $field1 = $row[\'field1\']; $field2 = $row[\'field2\']; $field3 = $row[\'field3\']; $sql = \"INSERT INTO $table3 ( field1, field2, field3 ) VALUES ( \'$field1\', \'$field2\', \'$field3\' )\"; $result = mysql_query ( $sql ); if ( mysql_affected_rows() > 0 ) { // Success } else { // Fail } }[/php:1:6ae32ffd94] That should get you started.
  6. If such a service exists, I\'ll eat my hat and/or any other convenient objects which will sufficiently convey my skepticism. edit: Probably not.
  7. Hey man. 1: Yes, it\'s possible. phpMyAdmin will let you import and export entire databases quite easily. 2: Aliases are just that. They\'re mainly used to help keep code cleaner and to prevent any data from being overwritten. If you performed a join on two tables, for instance, and they both had an ID field and you needed to select them BOTH, you could give the first ID field an alias so that it wouldn\'t be overwritten by the second ID field. It works for both field names and table names. Example: [php:1:265a818570]$sql = \"SELECT table1.id AS id1, table2.id AS id2 FROM some_really_long_table_name_omfg AS table1 LEFT OUTER JOIN some_even_longer_table_name_wtf AS table2 ON table1.id = table2.id WHERE id1 = \'$id\'\"[/php:1:265a818570] The key is the AS command. The general syntax is [table|table.field|field] AS [alias]. NOTE: You can only use field aliases in a WHERE clause (notice how I didn\'t use \'table1.id\' instead of just \'id1\' in the query). Table aliases will only give you an error. 3: Unsigned is a property of integer field types. It simply means that they cannot have negative values. This is good to have with ID fields. 4: I\'m not sure I understand you. Did the script tell you to grant the user a MySQL account with read-only access or did it simply say that it wouldn\'t let the user alter anything in the database when it is run? If the latter is the case, then yeah, it probably meant the user only has access to the SELECT command. 5: Nope, the OS doesn\'t really matter. Everything is stored the same way regardless of operating environment.
  8. \"SELECT * from LINKS ORDER BY id DESC LIMIT 5,0\" That should do it.
  9. There\'s an extra parenthesis at the end of your update query. And ditto about the single quotes.
  10. You got it. Your echo statement is a little off, though: [php:1:753995bc06]echo \"Your real name is: $real_name\";[/php:1:753995bc06] When using double quotes, you can include variables in your echos without having to worry about running into any parsing errors (for the most part, anyway).
  11. [php:1:3b4f32b051] $sql = \"SELECT TeamName FROM TableTeams WHERE TeamName.teamID != TableFixtures.HomeTeamID AND TeamName.teamID != awayTeamID AND TableFixtures.timStam > [value1] AND TableFixtures.timStam < [value2]\" [/php:1:3b4f32b051] Value 1 and Value 2 will be your two limiting values, obviously. In all honesty, though, I think you\'re better off using two separate queries. This type of join isn\'t very efficient, imo.
×
×
  • 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.