Jump to content

Delaran

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Delaran's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey all, I've tried this a few different ways and maybe I need to do with with straight SQL. I thought maybe someone here may know, so here goes: I have two tables I need values from and I am trying to create a third composed of the fields from both that I need. Let's say table 1 has id, name, description and table 2 has price, amount per case, quantity on hand, etc. I tried using the operations panel but found no option to do just this. I used the export function and got an SQL file saved to my desktop, but it attempts to create a table when I try to import it... is there a way to select certain fields from a table and copy them to another?
  2. well, I suppose we may as well close this topic and say it is solved since the resolution is that I can't.
  3. Well, I had thought about doing that, but the problem is that the server it is currently on is available for the public to access. We have a php page that I've created that pushes POST data to the next page "action.php", which inserts the data into the database on the external server (public server). One of my co-workers suggested putting the admin page I've created on an internal server that the public cannot access to prevent them from tampering with the database. So, if I was to move the database from the external (public) to the internal (private), than "action.php" would not insert data correctly because the database has been moved to another server, right? I tried using some of the $_SERVER functions to the action page so that it would insert the data to the remote internal server and have gotten nothing so far. Any ideas?
  4. Hey guys, It's been a while since I've posted here but I've got a question that I hope someone can help me with. I'm very close to figuring out the syntax for this command, but can't seem to get it to work. My problem is, my company has moved our admin page to an internal server so no one can tamper with it externally. However, our database is still running externally on another server. By figuring out this "login" or "connection" issue I'm having here, than we could even move the database to an internal site. This is what I am using to open my db: // set path of database file $db = $_SERVER['SERVER_ADDR']."68.178.4.77/../wantdb.sdb"; $handle = sqlite_open($db) or die("Could not open database"); It returns result: Could not open database So I feel as if I am getting closer, maybe it has something to do with a username/password used to log in to the remote server? Anyone have a suggestion as to how or what $_SERVER command I should use? I get the feeling it is not SERVER_ADDR I should be using but I'm not sure. ~del
  5. So should I create three text fields on the first page to signify area code, middle, and latter areas in the phone number, then assign their own $_POST values to call? I would assume the way it would work would be something similar to: <?php <p>Phone number * <br><input type="text" name="areacode" size="3" maxsize="3" /><input type="text" name="midnum" size="3" maxsize="3" /><input type="text" name="lastnum" size="4" maxsize="4" /></p> ?> And to call this, I would use: <?php // Name of form fields $a = $_POST['areacode']; $b = $_POST['midnum']; $c = $_POST['lastnum']; $result =$a."-".$b."-".$c; we will contact you at echo $result ?>
  6. Not that it matters here, but when/if this thread is moved the correct syntax was: create trigger purge_old_entry after insert on wantdb begin delete from wantdb where timestamp = datetime('now', '-2 months'); end;
  7. Hey all, I'm certain this thread belongs in this forum Anyway, I'm at the point where I am calling the $_POST data inserted in a text field from the previous page. However, if the user inserts their phone number in the field as: "555-555-5555" than it will return on the next page as: "555" and omit the rest. However, if entered as: "5555555555" it returns as "5555555555". Obviously the dashes are being omitted and everything beyond them. Stripslashes has not worked for me. My code is as follows: we will contact you at <?php echo stripslashes((int)($_POST['phone'])); ?> Please help!
  8. oops, i realized this is the wrong forum. Can I get this moved if any moderators have time? Sorry!
  9. create trigger purge_old_timestamp after insert on wantdb begin delete * from wantdb where timestamp > datetime('now', '-2 months') end; How do I get this statement to delete entries older than two months? Do I already have the syntax correct?
  10. omg I really can't figure this out. If I keep the code as: /* helper function for insert_areas(). generates the sctual SQL query */ function create_checkbox_query($arr, $table) { print("Function: create_checkbox_query called<br>"); foreach ($arr as $check); $q = "INSERT INTO listing_areas (section, checked, specialty) VALUES ( $section, $check , $specialty )"; print("Query is $q"); /* remove the last comma and return */ return substr($q, 0, -1); } It returns error -- Query is INSERT INTO listing_areas (section, checked, specialty) VALUES ( , 8 , )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 ' 8 ,' at line 1 However, when I remove the bottom part: /* helper function for insert_areas(). generates the sctual SQL query */ function create_checkbox_query($arr, $table) { print("Function: create_checkbox_query called<br>"); foreach ($arr as $check); $q = "INSERT INTO listing_areas (section, checked, specialty) VALUES ( $section, $check , $specialty )"; print("Query is $q"); It returns error -- Query is INSERT INTO listing_areas (section, checked, specialty) VALUES ( , 8 , )Query was empty I'm completely stuck. These three bits of data are being sent as POST and I am escaping their strings, but nothing shows up.
  11. Alright, I get this error message: SQL query is INSERT INTO listing_areas (directory_listing_id, section, checked, specialty) VALUESYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , 1 , ), ( , , 4 , )' at line 1 Basically, I modified my code and added those mysql_error() codes, along with a print statement to show the exact statement. The problem lies somewhere in this code: function create_checkbox_query($arr, $table) { print("Function: create_checkbox_query called<br>"); $q = "INSERT INTO listing_areas (directory_listing_id, section, checked, specialty) VALUES"; print("SQL query is $q"); foreach ($arr as $check) { $q .= " ( $id , $section, $check , $specialty )" . ","; } /* remove the last comma and return */ return substr($q, 0, -1); } But I'm not sure where. I'll try to play around with it.
  12. Hey guys, I'm here again with another novice question. I feel like I should know this one since I went over every tutorial I could find but for some reason, I just can't get this to work. It runs the whole script and tells me that the data was entered correctly, however when I query the database via phpmyadmin it returns -no results-. Obviously, something is wrong. I checked my connection, used multiple print lines to see where it was stopping and it isn't. The code thinks it is inserting these statements no problem, but in reality it isn't. Anyone have suggestions? Code is as follows: /* assign variables */ $id = mysql_escape_string($_GET['id']); $section = mysql_escape_string($_POST['section']); $specialty = mysql_escape_string($_POST['specialty']); /* the function we call to insert.*/ function insert_areas($areas) { print("Function: insert_areas called<br>"); /* create the sql insert query */ $query = create_checkbox_query($areas, "listing_areas"); /* execute the query */ mysql_query($query); } /* helper function for insert_areas(). generates the sctual SQL query */ function create_checkbox_query($arr, $table) { print("Function: create_checkbox_query called<br>"); $q = "INSERT INTO listing_areas (id, section, checked, specialty) VALUES"; foreach ($arr as $check) { $q .= " ( $id , $section, $check , $specialty )" . ","; } /* remove the last comma and return */ return substr($q, 0, -1); } print("<p>At end of php, now I need to call the insert function<p>"); insert_areas($_POST['areas']); ?> All done, entries entered correctly. <br> <a href="http://moogar.home/~pwalton/main.php">Insert/update another entry?</a> </html> As always, any help is much appreciated! I've been banging my head on the desk for hours now.
  13. Have you changed them to reflect your server move?
  14. Ok, so I've gotten my second page to reflect the choices from the first (ie. the name of the company/id via the $_GET command). This is displayed at the top of the page along with a stripslashes command to ignore apostrophes. When I get to your step 2.3 where you say to add a hidden input field, I decided to try changing the field momentarily to a text field. It displays nothing more than the text "$_GET['id']" etc. how would I go about making this string? I have: <input type="text" name="idnum" value=$_GET["id"]> <input type="text" name="conam" value=$_GET["cid"]> (type was changed to text to check if I am inserting it properly. I have tried using quotes around the $_GET field already)
×
×
  • 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.