Jump to content

cmattoon

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Everything posted by cmattoon

  1. Ahhhhhhhh. That's strange, I believe I've used "to" as a field before with no problems.. And yeah, those quotes were just me trying different arrangements out of frustration. Thanks!
  2. I'm using a PM script from here: http://www.pixel2life.com/publish/tutorials/608/simple_private_messaging_system/ and can't get the messages to send. This is the relevant section of code (from the PHP class), along with the mysql_error() output. function sendmessage($to,$title,$message) { $to = $this->getuserid($to); //$sql = "INSERT INTO messages SET 'to' = '".$to."', 'from' = '".$this->userid."', 'title' = '".$title."', 'message' = '".trim($message)."', 'created' = NOW()"; $created = time(); $sql = "INSERT INTO messages ('to,from,subject,message,created') VALUES ('$to','$this->userid','$title','".trim($message)."','$created')"; return (@mysql_query($sql)) ? true : false; } 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 ''to,from,subject,message,created') VALUES ('5','1','test','This is a test Messag' at line 1 I have tried the original code (commented out), as well as the subsequent two lines with several variations in quotes. Each one results in this message. The trim() on the second one was also attempted with just '$message', and did not work. The values in the INSERT statement are correct, as far as I can tell. The only potential difference is the integers are actually strings, being put into an INT(11) field on the DB...but I've never had a problem with this before. I've also tried re-ordering the query to match the order of fields in the database (title,message,to,from,created). $sql = "INSERT INTO messages (title,message,to,from,created) VALUES ('$title','".trim($message)."','$to','$this->userid','$created')"; This results in the error showing: 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 'to,from,created) VALUES ('test','This is a test Message','5','1','1318345125')' at line 1 It appears to be a problem with the "to"? I've never had this problem before...am I missing something?
  3. I have a checkbox with an ID and NAME of "noexpire", and a Spry textbox with an ID and NAME of "expiration". When the user checks the "noexpire" checkbox, I want the date "12/31/2099" to automatically populate the textbox. I've tried several different arrangements of: document.frmPass.expiration document.getElementById('expiration') document.getElementById("expiration") as well as a few others, but for some reason, nothing appears to work. I'm not even getting a JavaScript error! (I've also tried ".value" for both the checkbox and textbox..) I tried an alert box, and the function is being accessed, but it won't do anything. function doExpire(){ document.getElementsByName("expiration").text=(document.getElementByName("noexpire").checked)?"12/31/2099":""; } Any ideas? Thanks!
  4. There's probably an easier way to do this, but here's what I do.. Suppose we have a table of stocks: ID Symbol Name 1 ABC ABC, Inc. 2 XYZ XYZ, Inc. ... Use the unique identifier (whatever that may be in your case).. in the example i'll use ID <select name="stockToModify"> while ($row = loop to pick all valid options) { echo "<option value=\"".$row[id]."\">".$row[symbol]."</option>"; } </select> Then, in your 2nd script (which processes form data): $id = $_POST['stockToModify']; $sql = mysql_query("SELECT * FROM stocks WHERE id='$id'"); ...perform operation, etc... Hope that helps!
  5. I borrowed a free script to make a basic news scroller with the use of an XML file. Basically, it loads the XML file, then does: document.all.write('<div id="news_panel"></div>'); Later on in the script, it does: document.all.getElementById(news_panel).innerHTML = '.......'; Up until recently, this has worked fine because it was on a test page by itself. However, when I integrate into the existing main page, I can't seem to put it where I want it. When I code the DIV as HTML, it doesn't want to write into that DIV using the 2nd line of code (above). It only seems to write when the DIV is written through the document.all.write() method. The other thing I tried was to code (in HTML) a <div id="mainNewsFrame"></div> and then write the news_panel DIV into the mainNewsFrame DIV, but that doesn't work either. I'm not sure what the document.ALL.getElementById() means either.. in previous JavaScript code I've seen, it's simply "document.write" or "document.getElementById()".. any idea what the "all" is for? (If you can't tell, I'm not very familiar with JavaScript!) Thanks!
  6. Let me preface this with "I know next to nothing about JavaScript, and usually can't even get a simple, pre-written JS function to run properly". What I'm trying to do is develop a series of HTML templates that provide pseudo-dynamic data on a local machine. For example, you could write a text file, name it "config.txt" and place it in the same directory as this template, zip it, and email it to me, and i open up the HTML file as a local file, and can view your content. Sample "config.txt" BACKCOLOR FFFFFF; TXTCOLOR 000000; :1: TXT "Hello World! This is a page of text."; IMG picture.png; CLICK next [2]; :2: TXT "This is page 2."; IMG picture2.png; CLICK back [1]; CLICK next [3]; I guess it is like Powerpoint meets batch files or QBASIC. I know it's a lot of work for something really silly, and if there's an easier way to do it, by all means - let me know. JavaScript is just the only client-side script I know of, and I'm even worse at Flash (IIRC, it has this capability with XML files). The question is, can you (how do you...) import this file with JavaScript, parse it, and somehow make the browser know which content to load. My hopes are to do something like PHP does: <img src="<?=$image;?>"> <a href="<?=$url;?>"><?=$linkText;?></a> .... Any thoughts? Thanks!
  7. Hi all, I recently put a live search box on a website, and it was working fine for the past few weeks. Suddenly, I receive the following error when the page is accessed via a link (after it's accessed, 'refresh' cures the problem) - but I'm not sure why it's showing up suddenly. The search box does not work when the error is shown. Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC; .NET4.0C; InfoPath.3; Zune 4.0) Timestamp: Sat, 22 Jan 2011 12:39:58 UTC Message: Object doesn't support this property or method Line: 3 Char: 3 Code: 0 URI: http://wwww....com/ajax_search.js Lines 1-9 of "ajax_search.js": function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your Browser Sucks!"); } } I've tried deleting the whitespace and replacing it, in hopes that character 3 was an invalid 'invisible' character, but that didn't work. I also uploaded the backup copy, in case it was the other guy who messed it up (which I doubt, since neither of us touch JS files that are working...purely for this reason..) Any thoughts? Thanks!
  8. +1 I've been working with lots of linked tables recently, where each tables' data is pertinent to each other (personnel records)... that does make it a lot easier though, and what i was starting at with part 1. Out of curiousity, why four separate tables? (I may be missing something obvious here... lol)
  9. Try using regex. This site has a few examples on URL regexes. I'm still not very good with them though.
  10. Simple Solution: -Products -------------- Colors --------------- Sizes -Foo --------------- Red ------------------ Small -Foo ---------------- Red ------------------ Med -Foo ---------------- Red ------------------ Large -Foo ---------------- Blue ------------------ Small -Foo ---------------- Blue ------------------ Med .....etc (SELECT * FROM table WHERE products='foo') Better: Products Table -- ID --- Description 1 Foo 2 Bar Colors Table -- ID --- Color 1 Blue 1 Red 2 Blue 2 Red Sizes Table -- ID --- Size 1 Small 1 Medium 2 Small 2 Medium Let's say we're on 'products.php?id=1'... shopping for "foo". We create dropdown boxes by: <select name="color"> <?php $sql = mysql_query("SELECT * FROM colors WHERE id='$id' ORDER BY color ASC"); while($row = mysql_fetch_assoc($sql)){ echo "<option value=\"".$row[color]."\">".$row[color]."</option>"; } ?> </select> then........... <select name="size"> <?php $sql = mysql_query("SELECT * FROM sizes WHERE id='$id' ORDER BY size ASC"); while($row = mysql_fetch_assoc($sql)){ echo "<option value=\"".$row[size]."\">".$row[size]."</option>"; } ?> </select> You may also want to add a numerical value for sizes, so they show up in a logical order, not alphabetical: ID size sizetxt 1 1 Small 1 2 Medium 1 3 Large 2 1 Small 2 2 Medium 2 3 Large This would show Sm/Med/Lg in that order... not "Large/Medium/Small"... or worse "Large/Medium/Small/X-Large/X-Small/XX-Large/XX-Small" In this case, you would do echo "<option value=\"".$row[size]."\">".$row[sizetxt]."</option>"; The 2nd method makes it easier to update your inventory... say you now offer Purple "foo".. just add a row to the "colors" table, and the sizes will pre-populate. This doesn't take into account that Red foo doesn't come in 2XL, only yellow and blue, etc... Disclaimer: There is probably a better/more efficient way to do this... but this is just my 0.02. (I'm no SQL expert, but I do use it quite a bit)
  11. ReCaptcha may be different than the Captcha script I've been using... but I dont see any code in your PHP script to check a value... it appears that you're only checking to see if they filled in a value. This may help: http://code.google.com/apis/recaptcha/docs/verify.html And This: http://code.google.com/apis/recaptcha/docs/php.html
  12. If you mean "dynamic" as in "live search" (think: google - updates as you type), you'll most likely want a PHP/AJAX/MySQL solution. Google "live search php", and you'll get a handful of tutorials. I have very limited experience with AJAX, and it took a few tries, but it's not too hard to do. If you're good with AJAX/JavaScript, it'll probably be a lot easier. On the other hand, if you mean 'dynamic', in the sense that clicking "Email Us" from the tech support page inserts "[email protected]", while clicking "Email Us" from the sales page inserts "[email protected]", that's a pretty easy chunk of PHP code. Lastly, and I've only ever needed this once, if you want a "dynamic" feature where there are checkboxes (Sales, Support, Billing), and you want the email addresses updated with the proper email addresses depending on the checkboxes that are checked, that can be done relatively easy with JS.
  13. Awesome, thanks! Cant believe that didn't turn up in the search or the stack of books here!
  14. I've searched around the internet and can't find a good method to do this. To start, I have a database with a field called 'fpath' that stores the filepath (root-relative) to uploaded PDF's. In this case, they're scanned personnel files. What I'd like to do is be able to download relevant PDF's based on a generated report... such as all PDF's of a certain category or all PDF's for a certain user. If there's a specific PEAR package or other script out there that you know works well, I can research it on my own.. but each search result is bringing up a different method to do it, which makes me nervous. Thanks!
  15. Its hard to say without knowing specifics of your SMS system. Typically, we use the mail() for our in-house projects ([email protected]). If you're using a commercial SMS gateway, it really depends on how the program works. I don't have much experience with them. To handle incrementing a value that's stored in the database, I'd probably set up a "listener" script that uses a GET request to increment the number. (pseudocode)... SMS gateway visits "listener.php?val=inc" $val=$_GET['val']; if($val == "inc"){ $sql = mysql_query("SELECT value FROM database"); $sql ++; $result = mysql_query("UPDATE value IN database"); if($result){ //Success }else{ //Fail } }else{ //Do nothing, invalid 'val' value. } Again, I have no idea what your SMS gateway supports.... this is just a general idea from what I've used with other listener scripts.
  16. Not sure if this is the right area or not, but I'm looking to implement a "buy credits" system on my website, and I have absolutely no idea where to start with this. Any recommendations on where to start looking, or how to go about this? Thanks!
  17. Hey, I'm writing an application that tracks attendance. There are multiple events ('events' table), in which members that are present will be found. (When an event file is uploaded, it has all members that attended the event, and adds the event entry in 'events', as well as adding each member to the 'attendance' table, with event_id(eid) and the 'did_attend' value as '1'. When the event is edited, it needs to find the other members that AREN'T in the events table, and add them to the 'attendance' table. When I use this code, it apparently keeps adding the same members. Will a LIMIT 1 stop this? I has about 65,000+ entries added before I stopped the execution of the script. Thanks! $sql2 = mysql_query("SELECT * FROM members WHERE status=1 ORDER BY mid ASC"); while($row = mysql_fetch_assoc($sql2)){ $sql3 = mysql_query("SELECT * FROM attendance WHERE event='$eid' ORDER BY member ASC"); while($row2 = mysql_fetch_assoc($sql3)){ if($row2[mid] == $row[mid]){ // if the member is in the attendance db, skip }else{ //if member is not in attendance, write zero--- causing multiple entries (50,000+) $qry = mysql_query("INSERT INTO attendance (member,event,did_attend) VALUES ('$row[mid]','$eid','0')"); if(!$qry){ die("SQL: ".mysql_error()); }else{ $msg = "<br />Member ".$row[mid]." marked as absent."; } } } }
  18. I know this has to be a really simple function, but it's totally escaping me today. I want to open a child window, find a result then change the parent's URL to the previous URL, plus a ?result= Example: parent.php is accessed (URL: "parent.php?foo=bar"). User clicks a link, which opens up a new window, and refreshes the parent window to: "parent.php?foo=bar&result=myresult" (parent.php can be accessed by a couple pages, where RESULT would be filled out, but if it's accessed alone, it needs to have the result paramater selected) Thanks!
  19. Thanks! I was using ORDER BY, DESC at first, but didn't have the LIMIT 1 in..
  20. I'm trying to select the highest/most recent trip number from a database. Trip numbers are in the format YY-#### (10-1000). When drivers go to enter trip information, the trip ID should automatically populate with the next available trip number (10-1001). When I use this code, it gives a result "-1". The database is up to 1300-1500 trips... any ideas? $sql = mysql_query("SELECT max(trip_id) FROM wcv2"); // should pull highest number only while($row = mysql_fetch_assoc($sql)){ $trip = $row['trip_id']; $trip = explode("-",$trip); $number = $trip[1]; // should be most recent trip # $newid = $trip[1] + 1; // New trip # (1234 only) $newid = $trip[0]."-".$newid; // 10-1234 }
  21. Still showing existing trips only? $sql2 = mysql_query("SELECT * FROM wcvschedule WHERE trip_date='$human_date' LEFT JOIN times ON wcvschedule.trip_time=times.txtime ORDER BY times.txtime"); $sql3 = mysql_query("SELECT * FROM wcvschedule, times WHERE times.txtime=wcvschedule.trip_time ORDER BY times.txtime"); //sql3 works, only shows trips that are entered..no blanks $sql4 = mysql_query("SELECT times.*, wcvschedule.* FROM wcvschedule LEFT JOIN times ON wcvschedule.trip_time=times.txtime WHERE wcvschedule.trip_date='$human_date' ORDER BY times.txtime"); $sql5 = mysql_query("SELECT * FROM wcvschedule LEFT JOIN times ON times.txtime=wcvschedule.trip_time WHERE wcvschedule.trip_date='$human_date' ORDER BY times.txtime"); while($row = mysql_fetch_assoc($sql5)){ if($row[khfd] == ""){ $khfd = ""; $trip_time = "<a href=\"../wcv/tx2.php?t=$row[trip_time]&d=$human_date\">$row[trip_time]</a>"; $ptid = NULL; }else{ $khfd = $row[khfd]; $trip_time = $row[trip_time]; $ptid = $row[pt_id]; } echo "<tr><td>$khfd</td><td>$trip_time</td><td>$row[ref_fac]</td><td>$row[rec_fac]</td><td>$row[pt_id]</td><td>$row[driver]</td><td>$row[status]</td></tr>"; }
  22. Is there a way to force an SQL query to display blanks for values that dont' exist? Once you select a date, it shows all scheduled events for that date, in half hour blocks. There are two half-hour blocks per time (see below). If something is scheduled, the time shows up as plain text, along with some information about the event. If there is nothing scheduled at that time, it shows no information (obviously), and displays the time as a link. When the user clicks the link, it takes them to a page to register an event (keeps people from over-booking). the times are displayed from $start to $end, as chosen on the first page. When I do a simple "generate times" php function, that prints two of each block on the screen from $start to $end, it works fine. When I use a standard SELECT * FROM where date='$date', it only displays the scheduled events. 07:00 07:00 07:30 07:30 08:00 08:00 08:30 08:30 etc... Maybe generate times, then fill the other table cells depending on query using a foreach?
  23. If I understand you correctly.... if query 1 is "true", go to option 2. if query 1 is false, go to option 3? Or: if 1 is false, go to 2. If 2 is false, go to 3? (True/False... goes to Option 2/Option 3) $next_option = 0; if(condition){ // condition 1 is true $next_option = 2; }else{ $next_option = 3; } if($next_option == 2){ // or.... if($next_option == 2) // Code for Option 2. Will only enter this part if condition 1 is "true" }else{} if($next_option == 3){ // Code for option 3. Will enter this part if condition 1 is "false" }else{} Otherwise, I would use a variable, say $flag = 0;. If a condition is satisfied, set $flag = 1;. Use separate if-then statements to see what the flag value is, and whether or not to enter that loop. There's probably an easier way to do this, but just my two cents.
  24. If I understand you correctly, you have the following SQL table ----------dbname.cake--------- ---caketype------cakevalue--- ---chocolate-------9.99---- ---marble-------- 10.99---- ----wedding----50.99--- So the first page would have: <form name="pickacake" action="getprice.php" method="post"> <input type="checkbox" name="chocolate" value="1"> Chocolate<br> <input type="checkbox" name="marble" value="1"> Marble<br> etc... </form> The second page will see which checkboxes are checked, then return the prices for the cake? <?php require_once("accessdb.php"); $chocolate = $_POST['chocolate']; $marble = $_POST['marble']; $wedding = $_POST['wedding']; echo "<table border=\"1\"><tr><td>Cake Type</td><td>Cake Value</td></tr>"; if($chocolate == 1){ $sql = mysql_query("SELECT * FROM cake WHERE caketype='chocolate'"); while($row = mysql_fetch_assoc($sql)){ $price = $row[cakevalue]; $type = $row[caketype]; echo "<tr><td>$type</td><td>$price</td></tr>"; } }else{} if($marble == 1){ $sql = mysql_query("SELECT * FROM cake WHERE caketype='marble'"); etc... There is probably a more simple way to handle the PHP, but that's a method I use that I know works. If you only want to view the price/value of one type of cake, consider using the following HTML, which creates a dropdown box with caketypes. (The same PHP would process a radio button with name="caketype"): <form name="pickacake" action="getprice.php" method="post"> <select name="caketype"> <option value="chocolate">Chocolate</option> <option value="marble">Marble</option> <option value="wedding">Wedding</option> </select> Then, your PHP would be: <?php require_once("accessdb.php"); $caketype = $_POST['caketype']; $sql = mysql_query("SELECT * FROM cakes WHERE caketype='$caketype'"); while($row = mysql_fetch_assoc($sql)){ echo "Cake: ".$row[caketype]."<br>"; echo "Price: ".$row[cakevalue]."<p>"; } If the Milk Tea Shop page is yours, consider formatting your currency to include decimal places. While most people will understand that ($5.5) is $5.50, it looks more professional if you have the trailing zeros ($1.00 instead of $1).
  25. I have a main window for entering information, one field is "patient name". Next to this field is a link that opens up a window via JavaScript. When I have a simple form (textbox, submit), it returns (child.textbox.value) to (mainwindow.textbox.value). The purpose of this "lookup" function is to search the database for patients with a last name of, say, Smith. It returns a table of all patients with a last name of Smith (also DOB, SSN, etc) Smith John 123-45-6789 12/31/1969 Smith Mike 234-56-7890 01/01/1970 etc... Next to each name is a checkbox, with a unique patient ID number as the value. This value and $lname.", ".$firstname should be returned to the main window. Main window >> Search for Patient >> Search Results/Select Patient >> Main window When I use two pages, it doesn't work. Main Window: (not sure what "Ratting" means... was in the sample code <input name="pt_name" type="text" id="pt_name" size="30" /><a style="font-size:x-small" href="javascript:void(0);" NAME="searchpt" title=" Patient Search " onClick=window.open("searchpt.php","Ratting","width=550,height=170,left=150,top=200,toolbar=0,status=1,");> Lookup</a> Search For Patient: <form method="post" action="../child_search.php"> (Input Text, Submit) Child_search.php: (The "frm" and action="") are exactly as laid out in the example, which works. I've also tried using the original code, which was just using "opener.document" instead of "mainWindow.document". The mainwindow body tag has an id/name of "mainWindow" <script langauge="javascript"> function post_value(){ mainWindow.document.form1.pt_name.value = document.frm.fullname.value; mainWindow.document.form1.pt_id.value = document.frm.ptid.value; self.close(); } </script> <form name="frm" action=""> (Search results) -- <input type="button" value="Select" onClick="post_value();">
×
×
  • 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.