[PHP] help with statement
I'm trying to take a paragraph then break it into linebreaks and grab each line separately but it's not working, I can get the paragraph but my lines are not I get the object id #6 or #7 everytime Here's my code // grab all the paragraphs on the page $xpath = new DOMXPath($dom); //$graphs = $xpath-evaluate(/html/body//p); $graphs=$dom-getElementsByTagName(p); $lines=$dom-getElementsByTagName(br); // Set $i =5 because first 5 paragraphs are not inspections for ($i = 5; $i+1 $graphs-length; $i++) { $paragraph = $graphs-item($i); $text = $dom-saveXML($paragraph); $text = trim($text); /* //my experiment for getting line br for ($b = 1; $b+1 $lines-length; $b++) {*/ $title = $lines-item($i); $addie= $lines-item($i); if($TESTING) echo br /$i Graph: . $text . br /; echo br /$line: . $title . br /; echo br/$line: . $addie . br/; // } } ? Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Report Moderator Abuse Here: http://www.freecycle.org/faq/faq/contact-info Or Email Your Complaint to: f...@freecycle.org or i...@freecycle.org Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a
Re: [PHP] How can I echo a javascript var in an email subject line? Possible? (Yes!)RESOLVED
Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Report Moderator Abuse Here: http://www.freecycle.org/faq/faq/contact-info Or Email Your Complaint to: f...@freecycle.org or i...@freecycle.org Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a On Wed, Apr 8, 2009 at 7:43 PM, Raymond Irving xwis...@yahoo.com wrote: For me its very easy to pass php values to the client: echo _var($value,'name'); But the best part is taking control of what your client sees from the server-side: C('#info')-show(); // now you see it ... C('#info')-hide(); // now you don't! Take control and start building powerful web apps with Raxan PDI - http://raxanpdi.com __ Raymond Irving Create Rich Ajax/PHP Web Apps today! Raxan PDI - http://raxanpdi --- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote: From: Michael A. Peters mpet...@mac.com Subject: Re: [PHP] How can I echo a javascript var in an email subject line? Possible? To: Terion Miller webdev.ter...@gmail.com Cc: PHP General php-general@lists.php.net Date: Wednesday, April 8, 2009, 2:34 PM Terion Miller wrote: On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com mailto:mpet...@mac.com wrote: Terion Miller wrote: javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Look at the various DOM functions - IE for input type=hidden name=wordcount id=hiddenStudd value= you coud do in your js: var myHidden = document.getElementById('hiddenStuff'); myHidden.setAttribute('value',$yourvalue); Thought I would go ahead and post a bit more on this, so here is my wordcount little function on the textarea of the form: textarea name=Comments cols=55 rows=5 wrap=hard onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300); onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php if (isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];} ?/textareabrLetters to the Editor are limited to 300 words or less.brWords remaining: input type=box readonly name=remLen size=3 value=300 So I was thinking I should be able to pass that again to the next page which is the emailform.php page that is taking all the id= and printing them to an email should be able to reuse that function right? input type=hidden id=words value= onSubmit=return wordCounter(this.form.Comments,this.form.remLen); or do I need to define the variable? think I'm starting to confuse myself lol You don't want the onSubmit in the the hidden input. I'm not a javascript guru - but I believe you can have the form onSubmit do the word count and insert it into the input field before the actual submit happens, I've never tried having an onsubmit function alter a value field though. I would change the textarea to have an id=Comments field and the remLen input to have an id=remLen field to make it easy to find via getElementById (as id attributes have to be unique), count the words and set them to a variable that then gets put into the hidden input before whatever function you run on the submit type onSubmit returns true. not tested - but something like this: function countTheWords() { var comment = $document.getElementById('Comments'); var remLen = $document.getElementById('remLen').value; var count = wordCounter
[PHP] Help on how to grab data from a page?
I'm trying to grab our towns restaurant inspection results , store them in a db ... I have a script that is able to pull the inspections and divides them by the paragraphs, now I need a way to grab each line (I think) so that I can hopefully store the data with fields like RestName, RestAddress etc... (I haven't created the db yet...) Anyone ever done this? here is my script so far, it works but I can't seem to get the line br part to do anything. ___script ?php $TESTING = TRUE; $target_url = http://www.springfieldmo.gov/health/database/foodinspections/index.jsp?st_pfx=nonecurrent_name=start_day=1end_year=2009start_month=1st_nmbr=end_month=4end_day=6Submit=Searchst_name=start_year=2009str_loc=noneoffset=0 ; $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 100); $html = curl_exec($ch); if (!$html) { echo br /cURL error number: .curl_errno($ch); echo br /cURL error: . curl_error($ch); exit; } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom-loadHTML($html); echo $html; $graphs = split(p, $html); // Start at 6 to clear out junk at top. Use $i+1 since last paragraph //is footnote that is not needed. for ($i = 6; $i+1 count($graphs); $i++) { if($TESTING) echo $i: $graphs[$i]br /; //split the paragraphs into lines $graphs-getAttribute('graphs'); $lines = split(br, $graphs); //for ($i = 1; $i+1 count($lines); $i++) { // Grab restaurant name if($TESTING) echo $i: $lines[$i]br /; } // Grab address // Grab city // Grab date and visit type Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Report Moderator Abuse Here: http://www.freecycle.org/faq/faq/contact-info Or Email Your Complaint to: f...@freecycle.org or i...@freecycle.org Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a
[PHP] How can I echo a javascript var in an email subject line? Possible?
I have a php form, that uses a javascript word counter to make sure submissions are a certain number of words, I have now been tasked with taking that word count and having it pass in the email that gets sent when someone submits a form ..in the subject line. Here is the code I'm using so far. Is it possible to just echo a javascript variable on a page like you can a php var? CODE= // Enter in a subject line for the email. $_SESSION['EmailSubject'] = Letter to the Editor echo('submitcount'); I want to just echo it..possible?? //Thank you text $_SESSION['ThankYou'] = Thank you for participating\\n\\nYour comments have been sent to our newsroom. \\nIf our writers or editors have any questions about your letter, you will receive a reply via phone or e-mail. ; ? script language=javascript var submitcount=0; function checkSubmit() { if (submitcount == 0) { submitcount++; document.Surv.submit(); } } function wordCounter(field, countfield, maxlimit) { wordcounter=0; for (x=0;xfield.value.length;x++) { if (field.value.charAt(x) ==field.value.charAt(x-1) != ) {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word. if (wordcounter 300) {field.value = field.value.substring(0, x);} else {countfield.value = maxlimit - wordcounter;} } } function textCounter(field, countfield, maxlimit) { if (field.value.length maxlimit) {field.value = field.value.substring(0, maxlimit);} else {countfield.value = maxlimit - field.value.length;} } /script ===END CODE== Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Report Moderator Abuse Here: http://www.freecycle.org/faq/faq/contact-info Or Email Your Complaint to: f...@freecycle.org or i...@freecycle.org Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Thanks
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com wrote: Terion Miller wrote: javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Look at the various DOM functions - IE for input type=hidden name=wordcount id=hiddenStudd value= you coud do in your js: var myHidden = document.getElementById('hiddenStuff'); myHidden.setAttribute('value',$yourvalue); Thought I would go ahead and post a bit more on this, so here is my wordcount little function on the textarea of the form: textarea name=Comments cols=55 rows=5 wrap=hard onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300); onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php if (isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];} ?/textareabrLetters to the Editor are limited to 300 words or less.brWords remaining: input type=box readonly name=remLen size=3 value=300 So I was thinking I should be able to pass that again to the next page which is the emailform.php page that is taking all the id= and printing them to an email should be able to reuse that function right? input type=hidden id=words value= onSubmit=return wordCounter(this.form.Comments,this.form.remLen); or do I need to define the variable? think I'm starting to confuse myself lol
[PHP] Help figuring out an uploading script problem...
I have this script that is no longer working to upload files, it goes thru the motions and says the file is uploaded but then there is NO file in the ArtWork folder any ideas? if ($_FILES) { for ($x=0; $x 15; $x++) { if (is_uploaded_file ($_FILES['Artwork']['tmp_name'][$x])) { $ImageExt = strtolower(end(explode('.', $_FILES['Artwork']['name'][$x]))); $ImageName = $_FILES['Artwork']['name'][$x]; $ImageSize = $_FILES['Artwork']['size'][$x]; list($width, $height, $type, $attr) = getimagesize($_FILES['Artwork']['tmp_name'][$x]); $sql = INSERT INTO images (ImageDate, ArtID, AdminID, ImageName, ImageType, ImageType2, ImageSize, ImageHeight, ; $sql .= ImageWidth, ImageAttr, Notes) VALUES (NOW(), '$ArtID', '$AdminID', '$ImageName', '$ImageExt',; $sql .= '$type', '$ImageSize', '$height', '$width', '$attr', '$Notes2'); mysql_query ($sql); $ImageID = mysql_insert_id(); $uploadfile = ../../Artwork/. $ArtID ._. $ImageID ... $ImageExt; move_uploaded_file($_FILES['Artwork']['tmp_name'][$x], $uploadfile); chmod($uploadfile, 0666); } } } Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Report Moderator Abuse Here: http://www.freecycle.org/faq/faq/contact-info Or Email Your Complaint to: f...@freecycle.org or i...@freecycle.org Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a
Re: [PHP] Help figuring out an uploading script problem...
On Mon, Mar 30, 2009 at 1:11 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Mon, 2009-03-30 at 11:44 -0500, Terion Miller wrote: I have this script that is no longer working to upload files, it goes thru the motions and says the file is uploaded but then there is NO file in the ArtWork folder any ideas? if ($_FILES) { for ($x=0; $x 15; $x++) { if (is_uploaded_file ($_FILES['Artwork']['tmp_name'][$x])) { $ImageExt = strtolower(end(explode('.', $_FILES['Artwork']['name'][$x]))); $ImageName = $_FILES['Artwork']['name'][$x]; $ImageSize = $_FILES['Artwork']['size'][$x]; list($width, $height, $type, $attr) = getimagesize($_FILES['Artwork']['tmp_name'][$x]); $sql = INSERT INTO images (ImageDate, ArtID, AdminID, ImageName, ImageType, ImageType2, ImageSize, ImageHeight, ; $sql .= ImageWidth, ImageAttr, Notes) VALUES (NOW(), '$ArtID', '$AdminID', '$ImageName', '$ImageExt',; $sql .= '$type', '$ImageSize', '$height', '$width', '$attr', '$Notes2'); mysql_query ($sql); $ImageID = mysql_insert_id(); $uploadfile = ../../Artwork/. $ArtID ._. $ImageID ... $ImageExt; move_uploaded_file($_FILES['Artwork']['tmp_name'][$x], $uploadfile); chmod($uploadfile, 0666); } } } Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Report Moderator Abuse Here: http://www.freecycle.org/faq/faq/contact-info Or Email Your Complaint to: f...@freecycle.org or i...@freecycle.org Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Well, there are many reasons this could fail, but you need to diagnose what is the actual problem. First, is it no longer working at all, or after a certain number of files are uploaded? I see you are trying to upload up to 15 files this way, are you sure that the combined file size is not greater than what your PHP setup can handle for a single post? Are the database inserts being performed correctly? If not, then PHP may be having problems seeing the uploaded files. Are there any error messages from this piece of code? Does the location to where you are attempting to move the files exist, and if so, does it have the correct permissions? Is there enough space on the drive/partition you are trying to move the files to? Lastly, the snippet of code you gave does not show where $ArtID was defined. Can you print out the query to see what it is actually doing? Ash www.ashleysheridan.co.uk Sorry guys I often forget to make sure I have clicked reply to ALL..and end up replying to just one of you: Thanks for the suggestions, the db inserts are working, all the info goes in, the only thing not working is there is no file in the Artwork file directory where the image is supposed to get moved. I will make sure the permissions are correct on the directory perhaps the hosting changed them? I thought the chmod command in the script would insure that the directory is writable.- Show quoted text - On Mon, Mar 30, 2009 at 12:09 PM, Bastien Koert phps...@gmail.com wrote: 2009/3/30 Terion Miller webdev.ter...@gmail.com I have this script that is no longer working to upload files, it goes thru the motions and says the file is uploaded but then there is NO file in the ArtWork folder any ideas? if ($_FILES) { for ($x=0; $x 15; $x++) { if (is_uploaded_file ($_FILES['Artwork']['tmp_name'][$x])) { $ImageExt = strtolower(end(explode('.', $_FILES['Artwork']['name'][$x]))); $ImageName = $_FILES['Artwork']['name'][$x]; $ImageSize = $_FILES['Artwork']['size'][$x]; list($width, $height, $type, $attr) = getimagesize($_FILES['Artwork']['tmp_name'][$x]); $sql = INSERT INTO images (ImageDate, ArtID, AdminID, ImageName, ImageType, ImageType2, ImageSize, ImageHeight, ; $sql .= ImageWidth, ImageAttr, Notes) VALUES (NOW(), '$ArtID', '$AdminID', '$ImageName', '$ImageExt',; $sql .= '$type', '$ImageSize', '$height', '$width', '$attr', '$Notes2'); mysql_query ($sql); $ImageID = mysql_insert_id(); $uploadfile = ../../Artwork/. $ArtID ._. $ImageID ... $ImageExt; move_uploaded_file($_FILES['Artwork']['tmp_name'][$x], $uploadfile); chmod
Re: [PHP] Help figuring out an uploading script problem...
The chmod in the script just ensures that the file you uploaded is given the correct permissions. Turn on all errors and warnings for the script so you can see where the problem is. Ash www.ashleysheridan.co.uk Thanks everyone, I figured it out, it was the directory permissions ...now it's working fine. Monday isn't so bad after all today!!
[PHP] Syntax checker? Character replacing
I have this and think maybe something is off, because if there is an amp () in the location then it only displays a comma , and nothing else: if (isset($_SERVER['QUERY_STRING'])) {$Page .= ($_SERVER['QUERY_STRING']? '?'. str_replace(,amp;,$_SERVER['QUERY_STRING']) : '');} is that wrong?
Re: [PHP] Re: [PHP-DB] Re: Problems with displaying results
On Tue, Mar 3, 2009 at 2:16 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 11:08 -0600, Terion Miller wrote: On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie nos...@mckenzies.net wrote: Terion Miller wrote: I have two queries one pulls out which users to use and the second pulls those users orders Looks something like this but is only pulling the first record: $query = SELECT `UserName`, `AdminID` FROM admin WHERE Key1 = 'YES' ; $result = mysql_query ($query) ; $row = mysql_fetch_assoc($result); //Reveal Variables for Debugging // include(VariableReveal2.php); echo (Hello br); //echo $row['AdminID']; echo ($row['UserName']); if ($row['Key1'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy = 'WorkOrderID DESC';} if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;} $PerPage = 30; $StartPage = ($Page - 1) * $PerPage; second query here is using the $row from the first (and yes I know not to use *, just did so here to keep post shorter) $sql= SELECT * FROM workorders WHERE AdminID = '.$row['AdminID'].' ; // $sql .= ORDER BY $SortBy LIMIT $StartPage, $PerPage; $result = mysql_query ($sql); $row2 = mysql_fetch_assoc($result); $Total = ceil(mysql_num_rows($result)/$PerPage); So this works but only half way as it only displays the first record in the table. Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Groucho Marx - I have had a perfectly wonderful evening, but this wasn't it. You need to lookup the mysql_fetch_assoc() function. It only returns one row from a result set that may contain multiple rows. You need something like: while($row = mysql_fetch_assoc($result)) { // do something with $row } --- well I looked it up in my book and tried this example but still get the same thing, the first record $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; //print a return for neatness sake echo \n; What happens if you just change your while loop to this: while($row = mysql_fetch_array($result)) { print_r($row); } Ash www.ashleysheridan.co.uk Still having problems with getting this script to work, the first part of the query does now work since I used the suggested JOIN, so my results are there and I can echo them but now I can't seem to get them to display neatly somehow: CODE THUS FAR $query = SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID, workorders.CreatedDate, workorders.Location, workorders.WorkOrderName, workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID) WHERE admin.Retail1 = 'yes' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ $admin_id = $row['AdminID']; for ($i=0; $imysql_num_fields($result); $i++); //echo $row[$i] . ; } if ($row['Retail1'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy = 'WorkOrderID DESC';} if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;} $PerPage = 30; $StartPage = ($Page - 1) * $PerPage; $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; $query .= ORDER BY $SortBy LIMIT $StartPage, $PerPage; $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executed query: ' . $query); $row2 = mysql_fetch_assoc($result); while ($row2 = mysql_fetch_row($result
[PHP] (SOLVEDV) Re: Problems with displaying results
Thanks everyone it was the WHILE I just moved the ending bracket and presto results show in tables... Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Carl Sagan - In order to make an apple pie from scratch, you must first create the universe. On Thu, Mar 5, 2009 at 11:25 AM, Lex Braun lex.br...@gmail.com wrote: On Thu, Mar 5, 2009 at 10:30 AM, Terion Miller webdev.ter...@gmail.comwrote: Still having problems with getting this script to work, the first part of the query does now work since I used the suggested JOIN, so my results are there and I can echo them but now I can't seem to get them to display neatly somehow: CODE THUS FAR $query = SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID, workorders.CreatedDate, workorders.Location, workorders.WorkOrderName, workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID) WHERE admin.Retail1 = 'yes' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ $admin_id = $row['AdminID']; mysql_fetch_row() returns a numerical array ( http://ca2.php.net/manual/en/function.mysql-fetch-row.php), but then you are trying to assign $admin_id using an associative array. Thus, you need to either return your row as an associative array ( http://ca2.php.net/manual/en/function.mysql-fetch-assoc.php) or assign $admin_id as a numerical array: Method 1: Use a numerical array $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $admin_id = $row[1]; // since it's the 2nd item in your SELECT ... } OR Method 2: Use an associative array $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { // returns result row as an associative array $admin_id = $row['AdminID']; }
[PHP] Problems with displaying results
I have two queries one pulls out which users to use and the second pulls those users orders Looks something like this but is only pulling the first record: $query = SELECT `UserName`, `AdminID` FROM admin WHERE Key1 = 'YES' ; $result = mysql_query ($query) ; $row = mysql_fetch_assoc($result); //Reveal Variables for Debugging // include(VariableReveal2.php); echo (Hello br); //echo $row['AdminID']; echo ($row['UserName']); if ($row['Key1'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy = 'WorkOrderID DESC';} if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;} $PerPage = 30; $StartPage = ($Page - 1) * $PerPage; second query here is using the $row from the first (and yes I know not to use *, just did so here to keep post shorter) $sql= SELECT * FROM workorders WHERE AdminID = '.$row['AdminID'].' ; // $sql .= ORDER BY $SortBy LIMIT $StartPage, $PerPage; $result = mysql_query ($sql); $row2 = mysql_fetch_assoc($result); $Total = ceil(mysql_num_rows($result)/$PerPage); So this works but only half way as it only displays the first record in the table. Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Groucho Marx - I have had a perfectly wonderful evening, but this wasn't it.
[PHP] Re: [PHP-DB] Re: Problems with displaying results
On Tue, Mar 3, 2009 at 10:32 AM, Shawn McKenzie nos...@mckenzies.netwrote: Terion Miller wrote: I have two queries one pulls out which users to use and the second pulls those users orders Looks something like this but is only pulling the first record: $query = SELECT `UserName`, `AdminID` FROM admin WHERE Key1 = 'YES' ; $result = mysql_query ($query) ; $row = mysql_fetch_assoc($result); //Reveal Variables for Debugging // include(VariableReveal2.php); echo (Hello br); //echo $row['AdminID']; echo ($row['UserName']); if ($row['Key1'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } if (isset($_GET['SortBy'])) {$SortBy = $_GET['SortBy'];} else {$SortBy = 'WorkOrderID DESC';} if (isset($_GET['Page'])) {$Page = $_GET['Page'];} else {$Page = 1;} $PerPage = 30; $StartPage = ($Page - 1) * $PerPage; second query here is using the $row from the first (and yes I know not to use *, just did so here to keep post shorter) $sql= SELECT * FROM workorders WHERE AdminID = '.$row['AdminID'].' ; // $sql .= ORDER BY $SortBy LIMIT $StartPage, $PerPage; $result = mysql_query ($sql); $row2 = mysql_fetch_assoc($result); $Total = ceil(mysql_num_rows($result)/$PerPage); So this works but only half way as it only displays the first record in the table. Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Groucho Marx - I have had a perfectly wonderful evening, but this wasn't it. You need to lookup the mysql_fetch_assoc() function. It only returns one row from a result set that may contain multiple rows. You need something like: while($row = mysql_fetch_assoc($result)) { // do something with $row } --- well I looked it up in my book and tried this example but still get the same thing, the first record $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; //print a return for neatness sake echo \n;
[PHP] Whats the correct syntax for using query results in a new query
I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Joe DiMaggio - Pair up in threes.
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk When I run the second query the one where the WHERE syntax is wrong if I put it like this I still get one record: SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID = '20' AND '61' AND '24' LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin the first query works and returns the records it should... which are 3 usernames and 3 adminID
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, Mar 3, 2009 at 2:51 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote: On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk When I run the second query the one where the WHERE syntax is wrong if I put it like this I still get one record: SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID = '20' AND '61' AND '24' LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin the first query works and returns the records it should... which are 3 usernames and 3 adminID What about joining the queries? SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID, workorders.CreateDate, workorders.Location, workorders.WorkOrderName, workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID) WHERE admin.Retail1 = 'yes' I know it looks like a mess, but it should do the trick Ash www.ashleysheridan.co.uk The joined query works as far as returning the records now I just have to get them to display and I'm good to go, thanks guys!
Re: [PHP] syntax
SELECT something FROM tbl_name - WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) = date_col; Taking that and changing it so it works for you would result in the following. $query .= WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) = `stamp`; Try that and let us know your results. */for the archives of course/* Jim Lucas Well, looking a little closer, you will need to change a little more. Try this instead. The first should work, but if it doesn't match, try the second. WHERE DATE_SUB(NOW(), INTERVAL 7 DAY) = `stamp`; or WHERE CONVERT(DATE_SUB(NOW(), INTERVAL 7 DAY), DATETIME) = `stamp`; also, check these to links out for more information: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add http://dev.mysql.com/doc/refman/5.1/en/cast-functions.html#function_convert Thanks for the suggestions Jim and everyone I will be trying them today, I realized yesterday that here I was trying to write date functions to pull records that were within 7 days which doesn't really work when the db has JUST been created and only has some fake records I added in it from the the same day..lol...now I'm wondering if I can put some in and just put in the mySQL timestamp in the stamp field myself or basically change it to reflect older records so I can test the stamp comparisons ...
[PHP] omg help...insane simple query won't work I must be blind
Ok guys, I'm going blind indeed, this is a simple tiny query that goes to a form and I get the error : Error, insert query failed ever since I added the fields StartDate and EndDate and advertiser what is going on here is the php ?php $ebits = ini_get('error_reporting'); error_reporting($ebits ^ E_NOTICE); //connect to database include 'inc/dbconnOpen.php'; //start script if(isset($_POST['add'])) { $href = $_POST['href']; $title = $_POST['title']; $blurb = $_POST['blurb']; $StartDate = $_POST['byear'] .-. $_POST['bmonth'] .-. $_POST['bday']; $EndDate = $_POST['eyear'] .-. $_POST['emonth'] .-. $_POST['eday']; $expos = $_POST['expos']; $advertiser = $_POST['advertiser']; $query = INSERT INTO `textads` (`title`, `href`, `blurb`, `StartDate`, `EndDate`, `expos`, `advertiser`) VALUES ('.$title.', '.$href.', '.$blurb.', '.$StartDate.', '.$EndDate.', '.$expos.', '.$advertiser.' ); echo $query; mysql_query($query) or die(mysql_error()); //handy variable view include (VariableReveal2.php); it's not showing anything either... echo New Dream Job Text Ad added br a href='enterForm2.php'Add New Ad/a; } else { ? And yes yes I know escape my strings ...I'll go back and do that when the stupid insert is actually working... Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Laurence J. Peter - If two wrongs don't make a right, try three.
Re: [PHP] omg help...insane simple query won't work I must be blind (RESOLVED)
Well I was going blind ready for a good laugh it was that the form was posting to the original page not the test page I was working with...um..DOH!! all things working now :) Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Henny Youngman - When I told my doctor I couldn't afford an operation, he offered to touch-up my X-rays. On Tue, Feb 24, 2009 at 2:08 PM, Daniel Brown danbr...@php.net wrote: On Tue, Feb 24, 2009 at 14:55, Terion Miller webdev.ter...@gmail.com wrote: And yes yes I know escape my strings ...I'll go back and do that when the stupid insert is actually working... I'd suggest that it's probably the reason your insert isn't working. Add your mysql_real_escape_string() stuff there, and then change your error bit to: ?php // mysql_query($query) or die(SQL: .$query.br /\nError: .mysql_error()); // ? -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out!
[PHP] syntax
Need syntax help when it comes to using a timestamp. What I'm trying to say in my query WHERE clause is to select records if the timestamp on the record is in the past 7 days from NOW() $query .= WHERE stamp NOW()-7 ; I have no clue here on this the lay language is WHERE stamp is within the past 7 days how to php that? lol Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Vince Lombardi - Winning is habit. Unfortunately, so is losing.
Re: [PHP] syntax
Has nothing at all to do with php. http://dev.mysql.com/doc/refman/5.0/en/datetime.html http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html Yeah guess I posted to the wrong list should of been on the php-db list maybe but thanks for the suggestions Marc I'll be trying yours out and also going to try *SELECT DATEDIFF('stamp','NOW()')= 7d; or something somehow like that... *
Re: [PHP] syntax
Nobody has asked to confirm, but what format is `stamp`? Unix Timestamp, MySQL Timestamp, MySQL Date stamp??? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare Hi Jim, stamp is a field in the db and I'm using the NOW() to populate it when a record is created and when I echo it to my excel sheet it looks like this: 2/24/2009 2:56:48 PM
Re: [PHP] Two troublesome fields (Resolved)
Wow do I feel blind..it was that I missed the ISSET part at the topdidn't have it for those two fieldsDOH!! Thanks all Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a P. J. O'Rourke - Everybody knows how to raise children, except the people who have them. On Fri, Feb 20, 2009 at 8:51 AM, Sean DeNigris s...@clipperadams.comwrote: *From: *Terion Miller webdev.ter...@gmail.com *Date: *February 19, 2009 5:34:50 PM EST *To: *Bastien Koert phps...@gmail.com *Cc: *PHP General php-general@lists.php.net *Subject: **Re: [PHP] Two troublesome fields* I just tried this and now it's not inserting at all where before everything EXCEPT two fields go in... $sql = INSERT INTO workorders ( CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes) VALUES (; $sql .= Now(), ; $sql .= '. mysql_real_escape_string($Location) .', ; $sql .= '. mysql_real_escape_string($WorkOrderName) .', ; $sql .= '. mysql_real_escape_string($AdminID) .', ; $sql .= '. mysql_real_escape_string(WorkOrder) .', ; $sql .= '. mysql_real_escape_string(New Order) .', ; $sql .= '. mysql_real_escape_string($Notes) .', ; $WorkOrderID = mysql_insert_id(); mysql_query($sql); There's no closing parethesis to VALUES, try... $sql .= '. mysql_real_escape_string($Notes) .'); Sean DeNigris s...@clipperadams.com
[PHP] Two troublesome fields
Hi all, I seem to be having a problem with getting two fields to insert into a table, the other fields insert but not these two its from a form that is a duplicate, basically I have a workorder that I want to make a copy of, I call it from the db, populate a form in case changes want to be made, and insert with a new unique ID as a new record, it's working great except Two fields will NOT insert and I'm at a loss for why ... the code is big so I will post snippets that I think may be the trouble spots Here is the insert: $sql = INSERT INTO workorders (CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes) VALUES (; $sql .= Now(), '$Location', '$WorkOrderName', '$AdminID', 'WorkOrder', 'New Order', '$Notes'); mysql_query($sql); $WorkOrderID = mysql_insert_id(); Here is the part where it calls the old values: $sql2 = SELECT Location, WorkOrderName FROM workorders WHERE WorkOrderID='$WorkOrderID'; $result2 = mysql_query ($sql2); $row2 = mysql_fetch_array($result2); Here is the form part: tr td align=left nowrapdiv class=CaptionReqProperty:/div/td td align=leftdivinput type=hidden name=Location value=?php echo $row2['Location']; ??php echo $row2['Location']; ? /div/td /tr tr td align=left nowrapdiv class=CaptionReqWork Order Name: ?php echo $row2['WorkOrderName']; ?/div/td td align=leftdivbrinput type=hidden name=WorkOrderName size=35 value=?php echo $row2['WorkOrderName']; ?//div/td /tr I need some clues, everything works except the two fields Location, and WorkOrderName. Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Bill Watterson - There is not enough time to do all the nothing we want to do.
Re: [PHP] How should I ....--its a date/timestamp issue (RESOLVED)
Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a George Burns - I would go out with women my age, but there are no women my age. On Wed, Feb 18, 2009 at 8:29 PM, Paul M Foster pa...@quillandmouse.comwrote: On Wed, Feb 18, 2009 at 05:25:16PM -0600, Terion Miller wrote: snip What about just accepting any date in to the system, and defaulting to the current date if any numptys/users try to set one before? Do something maybe like this (untested) $userDate = strtotime($_REQUEST['date']); $startDate = ($userDate time())?time():$userDate; From there, you can use the timestamp how you wish. OOH found it: $startday = mktime(0, 0, 0, date(m) , date(d)+2, date(Y)); Well no, guess I didn't find it because that code above gives me this 1235109600 What is that?? It's a *nix timestamp number. Give it to date() this way: date('Y-m-d', $startday) And you'll see the date it represents. (It's actually the number of seconds since, the Unix epoch, in 1970.) Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Two troublesome fields
Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Emo Philips - I was the kid next door's imaginary friend. On Thu, Feb 19, 2009 at 2:31 PM, Bastien Koert phps...@gmail.com wrote: On Thu, Feb 19, 2009 at 3:21 PM, Terion Miller webdev.ter...@gmail.comwrote: Hi all, I seem to be having a problem with getting two fields to insert into a table, the other fields insert but not these two its from a form that is a duplicate, basically I have a workorder that I want to make a copy of, I call it from the db, populate a form in case changes want to be made, and insert with a new unique ID as a new record, it's working great except Two fields will NOT insert and I'm at a loss for why ... the code is big so I will post snippets that I think may be the trouble spots Here is the insert: $sql = INSERT INTO workorders (CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes) VALUES (; $sql .= Now(), '$Location', '$WorkOrderName', '$AdminID', 'WorkOrder', 'New Order', '$Notes'); mysql_query($sql); $WorkOrderID = mysql_insert_id(); Here is the part where it calls the old values: $sql2 = SELECT Location, WorkOrderName FROM workorders WHERE WorkOrderID='$WorkOrderID'; $result2 = mysql_query ($sql2); $row2 = mysql_fetch_array($result2); Here is the form part: tr td align=left nowrapdiv class=CaptionReqProperty:/div/td td align=leftdivinput type=hidden name=Location value=?php echo $row2['Location']; ??php echo $row2['Location']; ? /div/td /tr tr td align=left nowrapdiv class=CaptionReqWork Order Name: ?php echo $row2['WorkOrderName']; ?/div/td td align=leftdivbrinput type=hidden name=WorkOrderName size=35 value=?php echo $row2['WorkOrderName']; ?//div/td /tr I need some clues, everything works except the two fields Location, and WorkOrderName. Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Bill Watterson - There is not enough time to do all the nothing we want to do. Why not try a insert into table select fields from table where id = $id -- Bastien Cat, the other other white meat I just tried this and now it's not inserting at all where before everything EXCEPT two fields go in... $sql = INSERT INTO workorders ( CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes) VALUES (; $sql .= Now(), ; $sql .= '. mysql_real_escape_string($Location) .', ; $sql .= '. mysql_real_escape_string($WorkOrderName) .', ; $sql .= '. mysql_real_escape_string($AdminID) .', ; $sql .= '. mysql_real_escape_string(WorkOrder) .', ; $sql .= '. mysql_real_escape_string(New Order) .', ; $sql .= '. mysql_real_escape_string($Notes) .', ; $WorkOrderID = mysql_insert_id(); mysql_query($sql);
Re: [PHP] How should I ....--its a date/timestamp issue
What are your suggestions folks on how to go about setting a date on a form so that a user can not set a start date prior to the current days date? I've been looking around php.net but is it a javascript thing in the validation I should be dealing with, basically as it is I have a form and a user can select a start date, but they should not be able to select a date that is past, currently the start date form is a drop down (a very long drop down) I would like to use one of those nifty calendar popups but am not sure (aka..wasn't able to figure out) how to send the date to the db fields as they are... guidance on this would be great ..how would you do it? thanks guys and gals Terion Broadly, you're either going to have to limit their choices going in to the form (limit the choices in the drop-down box), or validate it afterwards and generate an error message if it's wrong. I've never seen one of those calendar gizmos that wasn't Javascript, except maybe for Ashley's (mentioned in another thread). And even at that, a PHP one won't be selectable the way you want unless you put radio buttons next to all the dates. And after all that, you'd still have to do some pre-processing of it to limit selections to current date and later. Paul -- Paul M. Foster What about just accepting any date in to the system, and defaulting to the current date if any numptys/users try to set one before? Do something maybe like this (untested) $userDate = strtotime($_REQUEST['date']); $startDate = ($userDate time())?time():$userDate; From there, you can use the timestamp how you wish. OOH found it: $startday = mktime(0, 0, 0, date(m) , date(d)+2, date(Y)); Well no, guess I didn't find it because that code above gives me this 1235109600 What is that??
[PHP] How should I ....--its a date/timestamp issue
What are your suggestions folks on how to go about setting a date on a form so that a user can not set a start date prior to the current days date? I've been looking around php.net but is it a javascript thing in the validation I should be dealing with, basically as it is I have a form and a user can select a start date, but they should not be able to select a date that is past, currently the start date form is a drop down (a very long drop down) I would like to use one of those nifty calendar popups but am not sure (aka..wasn't able to figure out) how to send the date to the db fields as they are... guidance on this would be great ..how would you do it? thanks guys and gals Terion
[PHP] going blind for looking...need eyes
Need eyes on this query, it is not inserting, I am going to highlight what/where I thought the problem is (there is no )but when I add the it then changes the syntax coloring on the rest of the code in my editor which makes me wonder if I'm wrong... argh. and either way it's not inserting ... - $sql = INSERT INTO admin (UserName, Password, Name, Email, Property, Department, AddWorkOrder, ; $sql .= ViewAllWorkOrders, ViewNewOrders, ViewNewArt, ViewPendingWorkOrders, ViewPendingArtwork, ViewCompletedArt, ; $sql .= ViewCompletedWorkOrders, SearchWorkOrder, EditWorkOrder, DelWorkOrder, ChangeStatus, AddEditAdmin; $sql .= ) VALUES( '$UserName', '$Password', '$Name', '$Email', '$Property', '$Department', '$AddWorkOrder', ; $sql .= '$ViewAllWorkOrders', '$ViewNewOrders', '$ViewNewArt', '$ViewPendingWorkOrders', '$ViewPendingArtwork', ; $sql .= '$ViewCompletedArt', '$ViewCompletedWorkOrders', '$SearchWorkOrder', '$EditWorkOrder', '$DelWorkOrder', ; $sql .= '$ChangeStatus', '$AddEditAdmin', '$ViewMyOrders'); $result = mysql_query($sql);
Re: [PHP] Blank page of hell..what to look for
Better yet, use a IDE the does code highlighting. This would point you to the problem rather quickly. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare Speaking of IDE, which do people on here prefer, I have been using Dreamweaver CS3 just because as originally a designer I was/am used to it... I did finally find the problem but moving an echo(damnit); from line to line commenting out everything below it...Oi ...is this ever going to get easier for me I often wonder...
Re: [PHP] Re: More questions about SESSION use
On Mon, Feb 2, 2009 at 4:18 PM, Chris dmag...@gmail.com wrote: Edmund Hertle wrote: 2009/2/1 Terion Miller webdev.ter...@gmail.com This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Those two lines after header() will not be executed. Yes they will because there is no 'exit'. Header is just a function call, if you want to stop processing you have to do it yourself. -- Postgresql php tutorials http://www.designmagick.com/ Is it better to use the session_register() could that be my issue ,although my sessions are passing from page to page so they are registered? right... is this part of that loose format that php coders just love and I hate..because it to me makes learning it hard... t.
Re: [PHP] Re: More questions about SESSION use
Just use a session_start() before any output to the server, and the sessions array will be available to your code. Ash www.ashleysheridan.co.uk Ah ha...and now I know why my O'reilly book Web Database Applications with PHP was so inexpensive... :) it's outdated...oops...
Re: [PHP] Re: More questions about SESSION use
Show the code where your session vars are written and I would prefer using isset() instead of empty() if you want to check if this var is set or not. -eddy Hi All, here is the index page where users login and the sessions are set: ?php //start session session_start(); //db connection include include(inc/dbconn_open.php) ; //errors on error_reporting(E_ALL); ini_set('display_errors', '1'); if (!empty($_POST['UserName']) !empty($_POST['Password'])) { $UserName = $_POST['UserName']; $Password = $_POST['Password']; } $msg = ''; if (!empty($UserName)) { $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user'] = $UserName; $_SESSION['AdminID'] = $row-AdminID; header ('Location: Main.php'); exit; } else { $msg = Sorry You Entered An Invalid LoginbrPlease Try AgainbrClick to Contact a href='mailto:b...@blahblah.com'bblah blah/b/a If You Need Help; } } //include (VariableReveal2.php); ?
Re: [PHP] Blank page of hell..what to look for
I just use error_reporting(E_ALL); that would include the E_NOTICE right? On Mon, Feb 2, 2009 at 11:27 AM, Richard Heyes rich...@php.net wrote: I have errors on Including E_NOTICE ? -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 31st)
[PHP] Blank page of hell..what to look for
Is there a certain thing that should be suspected and looked at first when getting the php blank page of hell I have errors on and nothing is being output anywhere to lead me in the right direction, I have a VariableReveal script (one of you provide and THANK YOU IT HAS BEEN A LIFESAVER) But it is doing nothing today, yesterday the page worked today I get the blank page with not a clue in sight ARGH... Terion
Re: [PHP] Re: More questions about SESSION use
This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Is the above part not needed since the Session is already active? Should I be not using the header part (honestly I havent read up on that chapter yet) Are you using session_start()? Cheers -- David Robley Hi David, yes I have session_start(); on everypage very 1st line. terio
[PHP] Weird url passing what does it mean, am I hacked?
I noticed yesterday that sometimes I was seeing a strange url passing at the bottom of the browser when clicking around my site I'm working on while watching the page loads, its calling to mouserunner.com and I went to the site and it is a bunch of links, my site is on a private server for a large media company, clues on what this means and where to look to stop it, what's it doing scraping my site or something? Thanks folks...
Re: [PHP] Weird url passing what does it mean, am I hacked?
On Sun, Feb 1, 2009 at 11:17 AM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Sun, 2009-02-01 at 11:01 -0600, Terion Miller wrote: On Sun, Feb 1, 2009 at 10:57 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sun, 2009-02-01 at 10:10 -0600, Terion Miller wrote: I noticed yesterday that sometimes I was seeing a strange url passing at the bottom of the browser when clicking around my site I'm working on while watching the page loads, its calling to mouserunner.com and I went to the site and it is a bunch of links, my site is on a private server for a large media company, clues on what this means and where to look to stop it, what's it doing scraping my site or something? Thanks folks... Are you using some of their content on your site? You may not realise it's come from them, it could be some Javascript you've found online and used on your site. It's more than likely just a call-back script to register a 'hit' along with other details. As for scraping your sites content, there is no way to prevent this. If your content is viewable for a human, it's viewable for a computer. Would you mind posting a link so we can see what you're seeing? Ash www.ashleysheridan.co.uk Hi Ash! My site isn't an outside app, it's an in house work order app hosted on our corporate servers, I was working on it yesterday and caught a glimpse in the bottom of the browser where you can see page loads , I kept seeing a www.mouserunner.com in there and was wondering what the hell...I googled and visited the site and found no other post anywhere complaining about this site or if it was a hacker/phishing site... Copying the list back in on this. You still haven't mentioned if you were using any scripts you sourced from elsewhere? Have you performed a search on the server in question for any files containing a link to that website? Ash www.ashleysheridan.co.uk no scripts that i've found, I inherited this app, and its about 57 pages 1200 lines each and I don't have access to the server corp rules...
Re: [PHP] Re: Session won't pick up one variable
On Fri, Jan 30, 2009 at 5:44 PM, Shawn McKenzie nos...@mckenzies.netwrote: Terion Miller wrote: Well I changed it because it's not a post since its not coming from a form is this closer? if (!empty($UserName)) { Why are you doing this? Only to see if 0 rows are returned? You can use the results you know. $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); Do you maybe mean $row['AdminID']? Well you're using objects now so $row-AdminID? $AdminId = $_SESSION['AdminID']; What in the hell are you doing here? If it's set then set it again to equal itself? if(isset($_SESSION['AdminID'])) $_SESSION['AdminID'] = $_SESSION['AdminID']; else $_SESSION['AdminID'] = $AdminID; If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; header ('Location: Main.php'); exit; } else { You either need to get a good PHP book or pay much closer attention to what you're doing. Many more problems, but those seem to cause your issue. This is not complete but seems to be the structure you need: session_start(); include(inc/dbconn_open.php); if (!empty($_POST['UserName']) !empty($_POST['Password'])) { $UserName = $_POST['UserName']; $Password = $_POST['Password']; $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user'] = $UserName; $_SESSION['AdminID'] = $row-AdminID; header ('Location: Main.php'); exit; } else { -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php yep I had actually tried your way my first try because it seemed to be what exactly it should do, but I get a blank pageno errors just a blank page, so I was suggested by someone else it was that the AdminID is not set, so that is why I was attempting to set it And for the record I have two O'reilly books on php...programming php, and web database applications with php, and the sessions section pretty much includes: session_start() and the oh so helpful $_SESSION($BLAH) = 'BLAH' I couldn't find anything about how to pull a result from the db and then use it to set a session, well anything past what seem to be common sense, to just put it after the query...and it does not pick up the adminID, and I've also tried another suggestion and also get a blank page, should I be setting the AdminID session on the page after the login? Here was the other way I tried : $UserName = (isset($_POST['UserName'])) ? mysql_real_escape_string($_POST[ 'UserName']) : ''; $Password = (isset($_POST['Password'])) ? mysql_real_escape_string($_POST[ 'Password']) : ''; if (!empty($UserName)) { $sql = SELECT `AdminID`,`UserName`,`Password` FROM `admin` WHERE `UserName`='$UserName'; $result = mysql_query($sql); $row = mysql_fetch_array($result); //If hashed passwords match proceed login if (sha1($Password) == $row['Password']) { //granted the password was sha1() before insertion into db $_SESSION['AdminID'] = (isset($_SESSION['AdminID'])) ? $_SESSION[ 'AdminID'] : $row['id']; $_SESSION['AdminLogin'] = true; $_SESSION['user'] = $UserName; header ('Location: Main.php'); } }
Re: [PHP] Re: Session won't pick up one variable (SOLVED)
thanks got it fixed: if (!empty($_POST['UserName']) !empty($_POST['Password'])) { $UserName = $_POST['UserName']; $Password = $_POST['Password']; } *---was missing a curly bracket..oi syntax* $msg = ''; if (!empty($UserName)) { $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user'] = $UserName; $_SESSION['AdminID'] = $row-AdminID; header ('Location: Main.php'); exit;
[PHP] More questions about SESSION use
So now I have SESSIONs set: user, AdminID, AdminLogin but I'm trying to use them without showing them in links...currently the pages only load if I make the links like this: a href=Welcome.php?AdminID=?php echo $_SESSION['AdminID']; ? target=mainFrameHome/a I thought the whole purpose of having/using Sessions is to not have to pass variables in url's, but if I remove the session in the link above when I click to it, It logs me out, even though it IS holding the SESSION (which I checked by revealing my variables) so I guess I am confused about this bit of code, I think its saying if the SESSION is there great if not logout... but even when I expose the variables and see that the session is passing from page to page it keeps sending me to the logout page: This is how it was originally written: if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; --*I added this one originally the script only used 'user' and 'AdminLogin'* but passed them in urls } Is the above part not needed since the Session is already active? Should I be not using the header part (honestly I havent read up on that chapter yet)
[PHP] Session won't pick up one variable
Think I'm setting this in the wrong place...someone help ...where do I set the AdminID session if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); if (isset($_POST['AdminID'])) {$AdminID = $_POST['AdminID'];} else {$AdminID= '';} If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; header ('Location: Main.php'); exit; } else {
[PHP] Re: Session won't pick up one variable
Well I changed it because it's not a post since its not coming from a form is this closer? ?php //start session session_start(); //db connection include include(inc/dbconn_open.php) ; //errors on error_reporting(E_ALL); ini_set('display_errors', '1'); if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); $AdminId = $_SESSION['AdminID']; if(isset($_SESSION['AdminID'])) $_SESSION['AdminID'] = $_SESSION['AdminID']; else $_SESSION['AdminID'] = $AdminID; If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; header ('Location: Main.php'); exit; } else { On Fri, Jan 30, 2009 at 4:20 PM, Terion Miller webdev.ter...@gmail.comwrote: Think I'm setting this in the wrong place...someone help ...where do I set the AdminID session if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT `AdminID`,`UserName` FROM `admin` WHERE `UserName`='$UserName' and`Password`='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); if (isset($_POST['AdminID'])) {$AdminID = $_POST['AdminID'];} else {$AdminID= '';} If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = true; $_SESSION['user']=$UserName; $_SESSION['AdminID']=$AdminID; header ('Location: Main.php'); exit; } else {
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
Hi Guys! Well I tried the INNER JOIN and still can not get it to echo the AdminID so I know it isn't working, (what kind of things should I think about that could make it not work) so far the only query that did work and return the AdminID was my original I believe it was referred to as hosed query, yet then it was explained to me that query while picking up the AdminID was then returning all the rows from workorders anyways because I needed the INNER JOIN, so since that isn't working, I'm thinking my best and fastest route ( I have until Monday on this project and this is just one bit of it OUCH) is to use my hosed query then somehow use the resulting AdminID to fetch the orders from the workorders table, question is , would that be a sub query, or do I just make the query results for AdminID a variable to use in another query? Thanks guys and ps. I'm a she not a he, funny that coders are primarily always assumed to be guys...lol Facebook Me: http://www.facebook.com/profile.php?id=1542024891ref=name Terion On Wed, Jan 28, 2009 at 7:39 PM, Shawn McKenzie nos...@mckenzies.netwrote: Chris wrote: The main problem is that you've never explained what you want to get from the query. The replies have used your code as an example and I'm pretty sure that's not what you want. Unless I totally mis-understand what you want, you have 2 options: 1. Use the 2 queries that I gave you in a previous post. 2. Use a subquery: $sql = SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin WHERE UserName = ' . mysql_real_escape_string($_SESSION['user']) . '); 3 - fix the join ;) Yes, however, I'm going out on a limb here because we don't really know what he wants - he is only getting admin.AdminID, workorders.AdminID returned in all of the queries I've seen. I'm assuming that he wants some of the workorder details. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
Hi Again Here is the query and code I tried: $sql = SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin WHERE UserName = ' . mysql_real_escape_string($_SESSION['user']) . '); $result2 = mysql_query ($sql); $row2 = mysql_fetch_assoc ($result2); $printrow = print_r($row2); Here is my print variables--- Nothing printed with the print_r: $sqlSELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin WHERE UserName = 'tmiller')$result2Resource id #6$row2$printrow1 So the subquery that I gave you doesn't work? Run it and then do a print_r($row); and post what you get. -Shawn Terion On Wed, Jan 28, 2009 at 7:39 PM, Shawn McKenzie nos...@mckenzies.net mailto:nos...@mckenzies.net wrote: Chris wrote: The main problem is that you've never explained what you want to get from the query. The replies have used your code as an example and I'm pretty sure that's not what you want. Unless I totally mis-understand what you want, you have 2 options: 1. Use the 2 queries that I gave you in a previous post. 2. Use a subquery: $sql = SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin WHERE UserName = ' . mysql_real_escape_string($_SESSION['user']) . '); 3 - fix the join ;) Yes, however, I'm going out on a limb here because we don't really know what he wants - he is only getting admin.AdminID, workorders.AdminID returned in all of the queries I've seen. I'm assuming that he wants some of the workorder details. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
Well upon looking it was number 2, I had no orders in the workorder table, but here is an oddity I wonder if someone can explain if I run this simple query: $query = SELECT * FROM admin, workorders WHERE admin.UserName = '.$_SESSION['user'].' ; It returns adminID = 7 (my number is 20) username= tmiller (this is correct) it's the only query I can get to return anything but it's the wrong adminID can someone explain what can be making that happen On Thu, Jan 29, 2009 at 2:48 PM, Shawn McKenzie nos...@mckenzies.netwrote: Terion Miller wrote: Hi Again Here is the query and code I tried: $sql = SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin WHERE UserName = ' . mysql_real_escape_string($_SESSION['user']) . '); $result2 = mysql_query ($sql); $row2 = mysql_fetch_assoc ($result2); $printrow = print_r($row2); Here is my print variables--- Nothing printed with the print_r: $sql SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin WHERE UserName = 'tmiller') $result2 Resource id #6 $row2 $printrow 1 O.K., easy: 1. There is no UserName in admin that = $_SESSION['user'] 2. Or, the AdminID that is returned for $_SESSION['user'] is not present in workorders That's why I suggested the 2 query approach the first time so that you could echo out the AdminID after the first query and then go into the db and make sure it exists in workorders. Or, if none were returned, then echo out $_SESSION['user'] and make sure it exists in admin. -Shawn
Re: [PHP] Re: Programming general question
On Wed, Jan 28, 2009 at 3:54 AM, Ondrej Kulaty kopyto...@gmail.com wrote: Depends on what for you want to use that. Array is simple data structure, it holds data, like variable, but objects has methods and properties, it acts as someting which can do some sort of task and you access it via it's interface (you call it's methods). You can use array for example to hold result from database and than iterate it with for or foreach cycle. On the other hand, object can be used for exaplme to send mail, you put into it text body, mail adresses and so on and then call it's method send() which causes mail to be send. The process of transforming data, generating headers etc is completely done by the object and it's internal methods, you access it only via it's well defined interface (it's methods you can call). Objects are mainly used in OOP programming, where they cooperate together. Good way to learn OOP is to learn something about design patterns... -- Terion Miller webdev.ter...@gmail.com pÃse v diskusnÃm prÃspevku news:37405f850901271518r21f5f73j44841e864de5c...@mail.gmail.com... I googled this and didn't find an answer my question is how do you know when to use an object or array would an object just be 1 instance, and array is several things together ( I know infantile coder language I use..but I'm a baby still in this) Can someone explain objects and arrays in plain speak for me? Thanks Happy Coding -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for all the information, I was asking because I inherited thousands of lines of code that had used mysql_fetch_object(), yet I kept getting so many errors so I starting playing with changing them to mysql_fetch_assoc() and things seem to work better, so I was wonder why sometimes data from a db field can be used as an object or array, the arrays, objects, classes still confuses me..oh add functions to that, is there a hiearchy?
[PHP] Making a Variable from different tables with Matching Db fields?
Not sure if I'm wording this right, what I am trying to do is look in two tables, match the ID to use to pull information Here's my code but it's not right, although it is picking up the user from the session, I will also post what my variable debugging lists: $query = SELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = '.$_SESSION['user'].' ; $result = mysql_query ($query); $row = mysql_fetch_assoc ($result); echo $row['AdminID']; if ($row['ViewMyOrders'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } *Also tried this to pull just this persons orders:* $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID ; $result = mysql_query ($sql); Thanks for looking, t.
[PHP] Re: Making a Variable from different tables with Matching Db fields?
Wow I got it !! Well I now have the AdminID variable to work with!! If I wasn't so tired and brain dead from marathoning this project because I'm so so So SICK of it, I would get up and do the happy dance On Wed, Jan 28, 2009 at 2:18 PM, Terion Miller webdev.ter...@gmail.comwrote: Not sure if I'm wording this right, what I am trying to do is look in two tables, match the ID to use to pull information Here's my code but it's not right, although it is picking up the user from the session, I will also post what my variable debugging lists: $query = SELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = '.$_SESSION['user'].' ; $result = mysql_query ($query); $row = mysql_fetch_assoc ($result); echo $row['AdminID']; if ($row['ViewMyOrders'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } *Also tried this to pull just this persons orders:* $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID ; $result = mysql_query ($sql); Thanks for looking, t.
Re: [PHP] Making a Variable from different tables with Matching Db fields?
Well I'm stuck I have the AdminID but now I can't seem to use it to pull workorders with that AdminID . I couldn't get your block to work Andrew :( I think I'm just not using it right now that I have it...lol On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard aball...@gmail.com wrote: On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller webdev.ter...@gmail.com wrote: Not sure if I'm wording this right, what I am trying to do is look in two tables, match the ID to use to pull information Here's my code but it's not right, although it is picking up the user from the session, I will also post what my variable debugging lists: $query = SELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = '.$_SESSION['user'].' ; $result = mysql_query ($query); $row = mysql_fetch_assoc ($result); echo $row['AdminID']; if ($row['ViewMyOrders'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } *Also tried this to pull just this persons orders:* $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID ; $result = mysql_query ($sql); Thanks for looking, t. Your first version gives you a Cartesian product containing more rows than you are expecting. (All rows from the workorders table joined with the row in the admin table where the username matches.) The second version returns all rows where the AdminIDs match, but for all users. You need to combine them: $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID AND admin.UserName = ' . mysql_real_escape_string($username) . '; Although I believe the preferred syntax (at least, I think it's the preferred) is $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders INNER JOIN admin ON workorders.AdminID = admin.AdminID WHERE admin.UserName = ' . mysql_real_escape_string($username) . '; Andrew
Re: [PHP] Making a Variable from different tables with Matching Db fields?
I just read it 3 times and I don't understand it. On Wed, Jan 28, 2009 at 3:22 PM, Christoph Boget christoph.bo...@gmail.comwrote: Well I'm stuck I have the AdminID but now I can't seem to use it to pull workorders with that AdminID . I couldn't get your block to work Andrew :( I think I'm just not using it right now that I have it...lol Because there is ambiguity w/r/t the columns you are selecting, you'll need to use aliases. http://dev.mysql.com/doc/refman/5.1/en/identifiers.html In your code, when you are referencing the column, do so using the alias. That should solve your problem. thnx, Christoph
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
On Wed, Jan 28, 2009 at 3:43 PM, Shawn McKenzie nos...@mckenzies.netwrote: Shawn McKenzie wrote: Terion Miller wrote: Well I'm stuck I have the AdminID but now I can't seem to use it to pull workorders with that AdminID . I couldn't get your block to work Andrew :( I think I'm just not using it right now that I have it...lol On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard aball...@gmail.com wrote: On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller webdev.ter...@gmail.com wrote: Not sure if I'm wording this right, what I am trying to do is look in two tables, match the ID to use to pull information Here's my code but it's not right, although it is picking up the user from the session, I will also post what my variable debugging lists: $query = SELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = '.$_SESSION['user'].' ; $result = mysql_query ($query); $row = mysql_fetch_assoc ($result); echo $row['AdminID']; if ($row['ViewMyOrders'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } *Also tried this to pull just this persons orders:* $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID ; $result = mysql_query ($sql); Thanks for looking, t. Your first version gives you a Cartesian product containing more rows than you are expecting. (All rows from the workorders table joined with the row in the admin table where the username matches.) The second version returns all rows where the AdminIDs match, but for all users. You need to combine them: $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID AND admin.UserName = ' . mysql_real_escape_string($username) . '; Although I believe the preferred syntax (at least, I think it's the preferred) is $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders INNER JOIN admin ON workorders.AdminID = admin.AdminID WHERE admin.UserName = ' . mysql_real_escape_string($username) . '; Andrew I think I see what you're trying to do: $query = SELECT AdminID FROM admin WHERE UserName = ' . mysql_real_escape_string($_SESSION['user']) . '; $result = mysql_query($query); $admins = mysql_fetch_assoc($result); $query = SELECT * FROM workorders WHERE AdminID = ' . $admins['AdminID'] . '; $result = mysql_query($query); $workorders = mysql_fetch_assoc($result); Well maybe not. Has anyone noticed that all the proposed selects including the OPs are only returning AdminID and WorkOrderID? But in the OPs code he's trying to use $row['ViewMyOrders']! -- Thanks! -Shawn http://www.spidean.com I have to get only the work orders associated with the adminID, I get the pages but no orders. and if I print my variables I am grabbing the right adminID but it's not then going and grabbing the work orders with it. I'm not up on the correct phrasing, been doing this about 2 months.
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
On Wed, Jan 28, 2009 at 4:00 PM, Shawn McKenzie nos...@mckenzies.netwrote: Terion Miller wrote: On Wed, Jan 28, 2009 at 3:43 PM, Shawn McKenzie nos...@mckenzies.net wrote: Shawn McKenzie wrote: Terion Miller wrote: Well I'm stuck I have the AdminID but now I can't seem to use it to pull workorders with that AdminID . I couldn't get your block to work Andrew :( I think I'm just not using it right now that I have it...lol On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard aball...@gmail.com wrote: On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller webdev.ter...@gmail.com wrote: Not sure if I'm wording this right, what I am trying to do is look in two tables, match the ID to use to pull information Here's my code but it's not right, although it is picking up the user from the session, I will also post what my variable debugging lists: $query = SELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = '.$_SESSION['user'].' ; $result = mysql_query ($query); $row = mysql_fetch_assoc ($result); echo $row['AdminID']; if ($row['ViewMyOrders'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } *Also tried this to pull just this persons orders:* $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID ; $result = mysql_query ($sql); Thanks for looking, t. Your first version gives you a Cartesian product containing more rows than you are expecting. (All rows from the workorders table joined with the row in the admin table where the username matches.) The second version returns all rows where the AdminIDs match, but for all users. You need to combine them: $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID AND admin.UserName = ' . mysql_real_escape_string($username) . '; Although I believe the preferred syntax (at least, I think it's the preferred) is $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders INNER JOIN admin ON workorders.AdminID = admin.AdminID WHERE admin.UserName = ' . mysql_real_escape_string($username) . '; Andrew I think I see what you're trying to do: $query = SELECT AdminID FROM admin WHERE UserName = ' . mysql_real_escape_string($_SESSION['user']) . '; $result = mysql_query($query); $admins = mysql_fetch_assoc($result); $query = SELECT * FROM workorders WHERE AdminID = ' . $admins['AdminID'] . '; $result = mysql_query($query); $workorders = mysql_fetch_assoc($result); Well maybe not. Has anyone noticed that all the proposed selects including the OPs are only returning AdminID and WorkOrderID? But in the OPs code he's trying to use $row['ViewMyOrders']! -- Thanks! -Shawn http://www.spidean.com I have to get only the work orders associated with the adminID, I get the pages but no orders. and if I print my variables I am grabbing the right adminID but it's not then going and grabbing the work orders with it. I'm not up on the correct phrasing, been doing this about 2 months. Well, try what I posted (needs some error checking). Where does ViewMyOrders come from? admin table? It would be even easier if you put the AdminID in the SESSION also :-) There also seems to be some design flaws. Why query the database for orders if the user is not allowed to view their orders? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php No the user is allowed to view them, or that is what I'm trying to do exactly , now I have it returning some orders but they don't belong to the correct AdminID , I'm getting closer, I appreciate everyone's help in the right direction!! Terion
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
On Wed, Jan 28, 2009 at 4:12 PM, Terion Miller webdev.ter...@gmail.comwrote: On Wed, Jan 28, 2009 at 4:00 PM, Shawn McKenzie nos...@mckenzies.netwrote: Terion Miller wrote: On Wed, Jan 28, 2009 at 3:43 PM, Shawn McKenzie nos...@mckenzies.net wrote: Shawn McKenzie wrote: Terion Miller wrote: Well I'm stuck I have the AdminID but now I can't seem to use it to pull workorders with that AdminID . I couldn't get your block to work Andrew :( I think I'm just not using it right now that I have it...lol On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard aball...@gmail.com wrote: On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller webdev.ter...@gmail.com wrote: Not sure if I'm wording this right, what I am trying to do is look in two tables, match the ID to use to pull information Here's my code but it's not right, although it is picking up the user from the session, I will also post what my variable debugging lists: $query = SELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = '.$_SESSION['user'].' ; $result = mysql_query ($query); $row = mysql_fetch_assoc ($result); echo $row['AdminID']; if ($row['ViewMyOrders'] == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } *Also tried this to pull just this persons orders:* $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID ; $result = mysql_query ($sql); Thanks for looking, t. Your first version gives you a Cartesian product containing more rows than you are expecting. (All rows from the workorders table joined with the row in the admin table where the username matches.) The second version returns all rows where the AdminIDs match, but for all users. You need to combine them: $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID AND admin.UserName = ' . mysql_real_escape_string($username) . '; Although I believe the preferred syntax (at least, I think it's the preferred) is $sql = SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID FROM workorders INNER JOIN admin ON workorders.AdminID = admin.AdminID WHERE admin.UserName = ' . mysql_real_escape_string($username) . '; Andrew I think I see what you're trying to do: $query = SELECT AdminID FROM admin WHERE UserName = ' . mysql_real_escape_string($_SESSION['user']) . '; $result = mysql_query($query); $admins = mysql_fetch_assoc($result); $query = SELECT * FROM workorders WHERE AdminID = ' . $admins['AdminID'] . '; $result = mysql_query($query); $workorders = mysql_fetch_assoc($result); Well maybe not. Has anyone noticed that all the proposed selects including the OPs are only returning AdminID and WorkOrderID? But in the OPs code he's trying to use $row['ViewMyOrders']! -- Thanks! -Shawn http://www.spidean.com I have to get only the work orders associated with the adminID, I get the pages but no orders. and if I print my variables I am grabbing the right adminID but it's not then going and grabbing the work orders with it. I'm not up on the correct phrasing, been doing this about 2 months. Well, try what I posted (needs some error checking). Where does ViewMyOrders come from? admin table? It would be even easier if you put the AdminID in the SESSION also :-) There also seems to be some design flaws. Why query the database for orders if the user is not allowed to view their orders? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php No the user is allowed to view them, or that is what I'm trying to do exactly , now I have it returning some orders but they don't belong to the correct AdminID , I'm getting closer, I appreciate everyone's help in the right direction!! Terion Here are my variables when I reveal them, I am picking up the right adminID I can't figure out why it's returning random orders though: $querySELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = 'tmiller' $resultResource id #5$rowkeyvalue[WorkOrderID] 44[AdminID]7$SortByWorkOrderID DESC$Page2$PerPage30$StartPage30 $sqlSELECT workorders.WorkOrderID, workorders.AdminID, admin.AdminID FROM workorders, admin WHERE workorders.AdminID = admin.AdminID $Total3
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
I'm not sure what you mean by trim the posts, please explain so I can spare folks from redundant text. Your post made perfect sense to me about the INNER JOIN , I looked it up but it is not returning the AdminID, maybe my syntax is wrong? $query = SELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN workorders ON AdminID(admin, workorders) WHERE admin.UserName = '.$_SESSION['user'].' ; $result = mysql_query ($query); $row = mysql_fetch_assoc ($result); echo $row['AdminID']; thanks again!! terion On Wed, Jan 28, 2009 at 4:28 PM, Chris dmag...@gmail.com wrote: Here are my variables when I reveal them, I am picking up the right adminID I can't figure out why it's returning random orders though: $querySELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE admin.UserName = 'tmiller' Please please please trim your posts to relevant stuff. I had to go through 4 pages of previous attempts to try and find what you posted. Trim it down to what you need to post. It's picking random stuff because you're not joining the tables properly. You have: select admin.AdminID, workorers.AdminID from admin, workorders WHERE admin.userName='tmiller'; You haven't told the db how to join the two tables together, so it's doing a cross or cartesian join (useful in some cases, but not here). What that means is for each row in 'admin', it will show every row in 'workorders' and vice versa. What you want is to only show rows that match up: select admin.AdminID, workorers.AdminID from admin inner join workorders using (AdminID) WHERE admin.userName='tmiller'; which means for every row in admin, make sure there is a matching row (based on the adminid) in workorders. -- Postgresql php tutorials http://www.designmagick.com/
Re: [PHP] Making a Variable from different tables with Matching Dbfields?
Your post made perfect sense to me about the INNER JOIN , I looked it up but it is not returning the AdminID, maybe my syntax is wrong? $query = SELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN workorders ON AdminID(admin, workorders) WHERE admin.UserName = '.$_SESSION['user'].' ; The syntax is wrong. inner join workorders using (adminid) ^^ only works if both tables are using the same field name, the db will expand it into the syntax below. Here you just need to specify the fieldname to join on (ie the common one). or inner join workorders on (admin.adminID=workorders.adminID) ^^ if the field names are not named the same, eg: select * from comments inner join users on (comments.user_id=users.id) Well I tried both ways and still cannot get it to pick up the AdminID, $querySELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN workorders on AdminID WHERE admin.UserName = 'tmiller' $result$row $SortByWorkOrderID DESC$Page1$PerPage30$StartPage0$sqlSELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN workorders ON AdminID(admin, workorders) WHERE admin.UserName = 'tmiller' $Total0
[PHP] Need Help resolving the undefined variable and getting property of non-object errors
Hello All, I am having problems resolving errors with some images causing the Undefined variable and getting property of non-object errors, I am trying to make a copy function so that an order can be viewed then resubmitted as a new order with minimal changes if needed. Here's my code: --could it be out of order as in the select should be above the insert? I bolded where the errors are happening. --- ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; } if (isset($_POST['AdminID'])){ $AdminID = $_POST['AdminID']; } elseif (isset($_GET['AdminID'])){ $AdminID = $_GET['AdminID']; } else { header (Location: LogOut.php); } if (isset($_POST['WorkOrderID'])){ $WorkOrderID = $_POST['WorkOrderID']; } elseif (isset($_GET['WorkOrderID'])){ $WorkOrderID = $_GET['WorkOrderID']; } else { header (Location: LogOut.php); } if (isset($_POST['ReturnPage'])){ $ReturnPage = $_POST['ReturnPage']; } elseif (isset($_GET['ReturnPage'])){ $ReturnPage = $_GET['ReturnPage']; } else { $ReturnPage = Welcome.php; } if (!empty($_POST['GO'])){$GO = $_POST['GO'];} else {$GO = ;} if (isset($_POST['Location'])){$Location = $_POST['Location'];} else {$Location = ;} if (isset($_POST['WorkOrderName'])){$WorkOrderName = $_POST['WorkOrderName'];} else {$WorkOrderName = ;} if (isset($_POST['IONumber'])){$IONumber = $_POST['IONumber'];} else {$IONumber = ;} if (isset ($_POST['AccountNum'])){$AccountNum = $_POST['AccountNum'];} else {$AccountNum = ;} if (!empty($_POST['BusinessName'])){$BusinessName = $_POST['BusinessName'];} else {$BusinessName = ;} if (!empty($_POST['URL'])){$URL = $_POST['URL'];} else {$URL = ;} if (!empty($_POST['Address1'])){$Address1 = $_POST['Address1'];} else {$Address1 = ;} if (!empty($_POST['Address2'])){$Address2 = $_POST['Address2'];} else {$Address2 = ;} if (!empty($_POST['City'])){$City = $_POST['City'];} else {$City = ;} if (!empty($_POST['State'])){$State = $_POST['State'];} else {$State = ;} if (!empty($_POST['Zip'])){$Zip = $_POST['Zip'];} else {$Zip = ;} if (!empty($_POST['Country'])){$Country = $_POST['Country'];} else {$Country = ;} if (!empty($_POST['Phone'])){$Phone = $_POST['Phone'];} else {$Phone = ;} if (!empty($_POST['TollFree'])){$TollFree = $_POST['TollFree'];} else {$TollFree = ;} if (!empty($_POST['Fax'])){$Fax = $_POST['Fax'];} else {$Fax = ;} if (!empty($_POST['Email'])){$Email = $_POST['Email'];} else {$Email = ;} if (!empty($_POST['Tagline'])){$Tagline = $_POST['Tagline'];} else {$Tagline = ;} if (!empty($_POST['Established'])){$Established = $_POST['Established'];} else {$Established = ;} if (!empty($_POST['StartMonth']) !empty($_POST['StartDay']) !empty($_POST['StartYear'])){ $StartDate = $_POST['StartYear'] .-. $_POST['StartMonth'] .-. $_POST['StartDay']; } else { $StartDate = ; } if (!empty($_POST['EndMonth']) !empty($_POST['EndDay']) !empty($_POST['EndYear'])){ $EndDate = $_POST['EndYear'] .-. $_POST['EndMonth'] .-. $_POST['EndDay']; } else { $EndDate = ; } if (!empty($_POST['PackageType'])){$PackageType = $_POST['PackageType'];} else {$PackageType = ;} if (!empty($_POST['BusinessType'])){$BusinessType = $_POST['BusinessType'];} else {$BusinessType = ;} if (!empty($_POST['MondayOpen'])){$MondayOpen = $_POST['MondayOpen'];} else {$MondayOpen = ;} if (!empty($_POST['MondayClose'])){$MondayClose = $_POST['MondayClose'];} else {$MondayClose = ;} if (!empty($_POST['TuesdayOpen'])){$TuesdayOpen = $_POST['TuesdayOpen'];} else {$TuesdayOpen = ;} if (!empty($_POST['TuesdayClose'])){$TuesdayClose = $_POST['TuesdayClose'];} else {$TuesdayClose = ;} if (!empty($_POST['WednesdayOpen'])){$WednesdayOpen = $_POST['WednesdayOpen'];} else {$WednesdayOpen = ;} if (!empty($_POST['WednesdayClose'])){$WednesdayClose = $_POST['WednesdayClose'];} else {$WednesdayClose = ;} if (!empty($_POST['ThursdayOpen'])){$ThursdayOpen = $_POST['ThursdayOpen'];} else {$ThursdayOpen = ;} if (!empty($_POST['ThursdayClose'])){$ThursdayClose = $_POST['ThursdayClose'];} else {$ThursdayClose = ;} if (!empty($_POST['FridayOpen'])){$FridayOpen = $_POST['FridayOpen'];} else {$FridayOpen = ;} if (!empty($_POST['FridayClose'])){$FridayClose = $_POST['FridayClose'];} else {$FridayClose = ;} if (!empty($_POST['SaturdayOpen'])){$SaturdayOpen = $_POST['SaturdayOpen'];} else {$SaturdayOpen = ;} if (!empty($_POST['SaturdayClose'])){$SaturdayClose = $_POST['SaturdayClose'];} else {$SaturdayClose = ;} if (!empty($_POST['SundayOpen'])){$SundayOpen = $_POST['SundayOpen'];} else {$SundayOpen = ;} if (!empty($_POST['SundayClose'])){$SundayClose = $_POST['SundayClose'];} else {$SundayClose = ;} if (!empty($_POST['BusinessCat'])){$BusinessCat = $_POST['BusinessCat'];} else {$BusinessCat = ;} if
[PHP] Programming general question
I googled this and didn't find an answer my question is how do you know when to use an object or array would an object just be 1 instance, and array is several things together ( I know infantile coder language I use..but I'm a baby still in this) Can someone explain objects and arrays in plain speak for me? Thanks Happy Coding
[PHP] Php and CSS where to put it
I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? link rel=stylesheet type=text/css href=inc/styles.css ?php include 'inc/dbconnOpen.php' ; ini_set('error_reporting', E_ALL); ini_set('display_errors', true); $sql = SELECT * FROM `textads` WHERE `expos` xCount ORDER BY RAND() LIMIT 3; $result = mysql_query($sql); echo table class=jobfont width=728 height=90 border=0 align=center cellpadding=10 bordercolor=#66 background= 'inc/bg.gif' bgcolor=#CC tr td table width=690 height=50 border=0 align=center cellpadding=5 tr; while ($row = mysql_fetch_array($result)) { echo td class=col align=center width=33%{$row['title']}br{$row['blurb']}br A HREF='{$row['href']}'{$row['href']}/a/td; //Add to exposure count $views = $row['xCount'] + 1; mysql_query(UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` = '{$row['ID']}'); } echo /tr /table/td/tr/table; ?
Re: [PHP] Re: Php and CSS where to put it
Resolved! Thanks! On Mon, Jan 12, 2009 at 12:38 PM, Michelle Konzack linux4miche...@tamay-dogan.net wrote: Hello Terion, Am 2009-01-12 10:42:10, schrieb Terion Miller: I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? The CSS must be in the HTML Header like html head titleCSS Example/title link rel=stylesheet type=text/css href=inc/styles.css style type=text/css #body { background-color: magenta; } /style /head body ...rest of the page link rel=stylesheet type=text/css href=inc/styles.css ?php include 'inc/dbconnOpen.php' ; ini_set('error_reporting', E_ALL); ini_set('display_errors', true); $sql = SELECT * FROM `textads` WHERE `expos` xCount ORDER BY RAND() LIMIT 3; $result = mysql_query($sql); echo table class=jobfont width=728 height=90 border=0 align=center cellpadding=10 bordercolor=#66 background= 'inc/bg.gif' bgcolor=#CC according to W3C any values must be quoted like: echo table class=\jobfont\ width=\728\ height=\90\ border=\0\ align=\center\ cellpadding=\10\ bordercolor=\#66\ background= \inc/bg.gif\ bgcolor=\#CC\ Do not forget to ESCAPE! And of course, I would put the stuff into the CSS definition and not into the TABLE tag. tr td table width=690 height=50 border=0 align=center cellpadding=5 QUOT the values! tr; while ($row = mysql_fetch_array($result)) { echo td class=col align=center width=33%{$row['title']}br{$row['blurb']}br A HREF='{$row['href']}'{$row['href']}/a/td; //Add to exposure count $views = $row['xCount'] + 1; mysql_query(UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` = '{$row['ID']}'); } echo /tr /table/td/tr/table; ? Your HTML page has to be closed with: /body /html Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 24V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ http://www.can4linux.org/ Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
Re: [PHP] Re: can a session be used in a query?
On Wed, Jan 7, 2009 at 8:28 PM, Paul M Foster pa...@quillandmouse.comwrote: On Wed, Jan 07, 2009 at 08:29:42PM -0500, Frank Stanovcak wrote: because you so nicely didn't make fun of me...that much :) I keep it in it's own file and just use it as in include to probe where I need to. --code follows-- ?php function breakarray($passed){ echo 'table border=1trthkey/ththvalue/th/tr'; foreach($passed as $tkey=$tvalue){ echo 'trtd[' , $tkey , ']/tdtd'; if(is_array($tvalue)){ breakarray($tvalue); }else{ echo '' , $tvalue , '/td/tr'; }; }; echo '/table'; }; echo 'table border=1tr thvariable/th thvalue/th /tr'; foreach(get_defined_vars() as $key = $value){ echo 'trtd$',$key ,'/tdtd'; if(is_array($value) and $key != 'GLOBALS'){ if(sizeof($value) 0){ breakarray($value); echo '/td/tr'; }else{ echo 'EMPTY /td/tr'; }; }else{ echo '' , $value , '/td/tr'; }; }; echo '/table'; ? Nicely done. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Good Morning Everyone Thanks for the snippet going to try that now, is it not okay to reuse the $row thru the code block, I do try and use it over and over to check for different fields data. I am going to go ahead and post the full block of code: --code ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; } $query = SELECT * FROM admin WHERE UserName = '.$_SESSION['user'].' ; $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executedquery: ' . $query); if (mysql_num_rows($result) = '1'){ while ($row = mysql_fetch_array($result)){ echo $row['AddEditAdmin']; //to print out the value of column 'var1' for each record } }else{ echo 'No records found.'; } ? html head meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 titleThe NEW Work Order System /title LINK REL=STYLESHEET HREF=inc/style.css /head body bgcolor=#006699 table width=180 border=0 cellpadding=0 cellspacing=0 tr td align=centerBR ? echo $row['AddEditAdmin'];? div class=admin_Title align=centerWork Order Systembr /div /td /tr tr tdHRYou are logged on as ?php echo $_SESSION['user'];?HR ?php echo $result;?br ?php echo $row;? HR/td /tr tr tddiv class=admin_linka href=Welcome.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameHome/a /tr tr tddiv class=admin_linka href=LogOut.php target=_parentLogOut/a/div/td /tr tr td align=centerBR?php echo $row['AddEditAdmin'];? div class=admin_Title align=centerYour Admin Tools/div/td /tr ?php if($row['AddEditAdmin'] === 'YES'){this is the only one I have been playing with.. ? tr tddiv class=admin_linka href=AddAdmin.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameAdd Admin/a/div/td /tr tr tddiv class=admin_linka href=ViewAdmin.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameView Admin/a/div/td /tr tr tddiv class=admin_linka href=ChangePassword.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameChange My Password/a/div/td /tr ?php } ? /div/td /tr tr td class=admin_TitleHRstrongBANNER ART REQUESTS/strongHR/td /tr ?php if ($row[AddWorkOrder] == YES) { ? tr tddiv class=admin_linka href=WorkOrder.php?AdminID=?php echo $_SESSION['AdminLogin']; ? target=mainFrameWork Order Form/a/divbr/td /tr /table /body /html end code- it's larger than this but you get the picture, I just need to get the $row to actually work, I don't understand why I can echo it at the top of the page and then not further down. Thanks for looking terion
Re: [PHP] Re: can a session be used in a query?
On Thu, Jan 8, 2009 at 8:21 AM, Terion Miller webdev.ter...@gmail.comwrote: On Wed, Jan 7, 2009 at 8:28 PM, Paul M Foster pa...@quillandmouse.comwrote: On Wed, Jan 07, 2009 at 08:29:42PM -0500, Frank Stanovcak wrote: because you so nicely didn't make fun of me...that much :) I keep it in it's own file and just use it as in include to probe where I need to. --code follows-- ?php function breakarray($passed){ echo 'table border=1trthkey/ththvalue/th/tr'; foreach($passed as $tkey=$tvalue){ echo 'trtd[' , $tkey , ']/tdtd'; if(is_array($tvalue)){ breakarray($tvalue); }else{ echo '' , $tvalue , '/td/tr'; }; }; echo '/table'; }; echo 'table border=1tr thvariable/th thvalue/th /tr'; foreach(get_defined_vars() as $key = $value){ echo 'trtd$',$key ,'/tdtd'; if(is_array($value) and $key != 'GLOBALS'){ if(sizeof($value) 0){ breakarray($value); echo '/td/tr'; }else{ echo 'EMPTY /td/tr'; }; }else{ echo '' , $value , '/td/tr'; }; }; echo '/table'; ? Nicely done. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Good Morning Everyone Thanks for the snippet going to try that now, is it not okay to reuse the $row thru the code block, I do try and use it over and over to check for different fields data. I am going to go ahead and post the full block of code: --code ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); $_SESSION['user']=$UserName; } $query = SELECT * FROM admin WHERE UserName = '.$_SESSION['user'].' ; $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executedquery: ' . $query); if (mysql_num_rows($result) = '1'){ while ($row = mysql_fetch_array($result)){ echo $row['AddEditAdmin']; //to print out the value of column 'var1' for each record } }else{ echo 'No records found.'; } ? html head meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 titleThe NEW Work Order System /title LINK REL=STYLESHEET HREF=inc/style.css /head body bgcolor=#006699 table width=180 border=0 cellpadding=0 cellspacing=0 tr td align=centerBR ? echo $row['AddEditAdmin'];? div class=admin_Title align=centerWork Order Systembr /div /td /tr tr tdHRYou are logged on as ?php echo $_SESSION['user'];?HR ?php echo $result;?br ?php echo $row;? HR/td /tr tr tddiv class=admin_linka href=Welcome.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameHome/a /tr tr tddiv class=admin_linka href=LogOut.php target=_parentLogOut/a/div/td /tr tr td align=centerBR?php echo $row['AddEditAdmin'];? div class=admin_Title align=centerYour Admin Tools/div/td /tr ?php if($row['AddEditAdmin'] === 'YES'){this is the only one I have been playing with.. ? tr tddiv class=admin_linka href=AddAdmin.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameAdd Admin/a/div/td /tr tr tddiv class=admin_linka href=ViewAdmin.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameView Admin/a/div/td /tr tr tddiv class=admin_linka href=ChangePassword.php?AdminID=?php echo $_SESSION['user']; ? target=mainFrameChange My Password/a/div/td /tr ?php } ? /div/td /tr tr td class=admin_TitleHRstrongBANNER ART REQUESTS/strongHR/td /tr ?php if ($row[AddWorkOrder] == YES) { ? tr tddiv class=admin_linka href=WorkOrder.php?AdminID=?php echo $_SESSION['AdminLogin']; ? target=mainFrameWork Order Form/a/divbr/td /tr /table /body /html end code- it's larger than this but you get the picture, I just need to get the $row to actually work, I don't understand why I can echo it at the top of the page and then not further down. Thanks for looking terion Ok ran the VariableReveal file and got this for $row $row so its not working? yet when I echo $row['AddEditAdmin']; at the top it returns the correct thing I'm lost
[PHP] Re: can a session be used in a query?
SOLVED: Thanks everyone I got it working it was the loop...took it out and now it works like a charm!! Is there a way to mark things solved? On Wed, Jan 7, 2009 at 1:46 PM, Terion Miller webdev.ter...@gmail.comwrote: I am still struggling with getting my sessions and logins to pull just the allotted data that each user is allowed... I have the session working, and can echo it to see that .. what I'm having problems with is this : I want to pull the data specific to each user ..right... so far I either get all data regardless of user privileges or I get nothing.. a blank page, I have tried so many ways but never one that works: here are a few I have worked with This one pulls all data regardless of user level: ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] 'True' ){ header (Location: LogOut.php); } $query = SELECT * FROM admin WHERE AdminID = AdminID; $result = mysql_query ($query); $row = mysql_fetch_object ($result); ? From there I tried: ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); } $query = SELECT * FROM `admin` WHERE `UserName` = `{$_SESSION['user']}; $result = mysql_query ($query); $row = mysql_fetch_assoc($result); ? this one didn't work with the if $row - statements that are used to select what menu items to load. Now I have this one which loads nothing, nil a blank page: $query = SELECT * FROM admin WHERE UserName = $_SESSION['user'] ; $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executedquery: ' . $query); if (mysql_num_rows($result) = '1'){ while ($row = mysql_fetch_assoc($result)){ echo $row['AddEditAdmin']; //to print out the value of column 'var1' for each record } }else{ echo 'No records found.'; } ? anyone have ideas for me, the session user is working, and I need to use it in the query to pull only that users data I also on the login page where I set that session all set it to = $UserName but when I try and use that in the query UserName = $UserName I get an undefined variable error... Really trying but not quite getting it...
[PHP] can a session be used in a query?
I am still struggling with getting my sessions and logins to pull just the allotted data that each user is allowed... I have the session working, and can echo it to see that .. what I'm having problems with is this : I want to pull the data specific to each user ..right... so far I either get all data regardless of user privileges or I get nothing.. a blank page, I have tried so many ways but never one that works: here are a few I have worked with This one pulls all data regardless of user level: ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] 'True' ){ header (Location: LogOut.php); } $query = SELECT * FROM admin WHERE AdminID = AdminID; $result = mysql_query ($query); $row = mysql_fetch_object ($result); ? From there I tried: ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); } $query = SELECT * FROM `admin` WHERE `UserName` = `{$_SESSION['user']}; $result = mysql_query ($query); $row = mysql_fetch_assoc($result); ? this one didn't work with the if $row - statements that are used to select what menu items to load. Now I have this one which loads nothing, nil a blank page: $query = SELECT * FROM admin WHERE UserName = $_SESSION['user'] ; $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executedquery: ' . $query); if (mysql_num_rows($result) = '1'){ while ($row = mysql_fetch_assoc($result)){ echo $row['AddEditAdmin']; //to print out the value of column 'var1' for each record } }else{ echo 'No records found.'; } ? anyone have ideas for me, the session user is working, and I need to use it in the query to pull only that users data I also on the login page where I set that session all set it to = $UserName but when I try and use that in the query UserName = $UserName I get an undefined variable error... Really trying but not quite getting it...
Re: [PHP] Re: can a session be used in a query?
On Wed, Jan 7, 2009 at 3:33 PM, Frank Stanovcak blindspot...@comcast.netwrote: One other thought. If you are getting a blank page with no errors or out put at all, I've noticed that I somtimes have to get the page to load successfully before the web server will dish out the error. What I normally do is upload a blank php page with the same name as the one I am working on, load it up, and then upload the page with all the code and refresh. I never really looked into why this was, but it's not that big of a hassle for me. *shrug* Frank Terion Miller webdev.ter...@gmail.com wrote in message news:37405f850901071146i11d33987ga747ef2e4932f...@mail.gmail.com... I am still struggling with getting my sessions and logins to pull just the allotted data that each user is allowed... I have the session working, and can echo it to see that .. what I'm having problems with is this : I want to pull the data specific to each user ..right... so far I either get all data regardless of user privileges or I get nothing.. a blank page, I have tried so many ways but never one that works: here are a few I have worked with This one pulls all data regardless of user level: ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] 'True' ){ header (Location: LogOut.php); } $query = SELECT * FROM admin WHERE AdminID = AdminID; $result = mysql_query ($query); $row = mysql_fetch_object ($result); ? From there I tried: ?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) || $_SESSION['AdminLogin'] != true){ header (Location: LogOut.php); } $query = SELECT * FROM `admin` WHERE `UserName` = `{$_SESSION['user']}; $result = mysql_query ($query); $row = mysql_fetch_assoc($result); ? this one didn't work with the if $row - statements that are used to select what menu items to load. Now I have this one which loads nothing, nil a blank page: $query = SELECT * FROM admin WHERE UserName = $_SESSION['user'] ; $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executedquery: ' . $query); if (mysql_num_rows($result) = '1'){ while ($row = mysql_fetch_assoc($result)){ echo $row['AddEditAdmin']; //to print out the value of column 'var1' for each record } }else{ echo 'No records found.'; } ? anyone have ideas for me, the session user is working, and I need to use it in the query to pull only that users data I also on the login page where I set that session all set it to = $UserName but when I try and use that in the query UserName = $UserName I get an undefined variable error... Really trying but not quite getting it... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well I am def. further along, the query is working, I can echo fields in the $row and get the results but when I try and use this: ?php if ($row['AddEditAdmin'] == 'YES') { ? to sort out what menu items to load it just doesn't do its job.
Re: [PHP] Re: can a session be used in a query?
On Wed, Jan 7, 2009 at 4:10 PM, Frank Stanovcak blindspot...@comcast.netwrote: Terion Miller webdev.ter...@gmail.com wrote in message news:37405f850901071354p7abd0aa8i7c96cf69c81fa...@mail.gmail.com... $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executedquery: ' . $query); if (mysql_num_rows($result) = '1'){ while ($row = mysql_fetch_assoc($result)){ echo $row['AddEditAdmin']; //to print out the value of column 'var1' for each record } }else{ echo 'No records found.'; } ? anyone have ideas for me, the session user is working, and I need to use it in the query to pull only that users data I also on the login page where I set that session all set it to = $UserName but when I try and use that in the query UserName = $UserName I get an undefined variable error... Really trying but not quite getting it... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well I am def. further along, the query is working, I can echo fields in the $row and get the results but when I try and use this: ?php if ($row['AddEditAdmin'] == 'YES') { ? to sort out what menu items to load it just doesn't do its job. I would say do this to see if what is in the return is what you are expecting foreach($row as $key=$value){ echo $key , ': ' , $value , 'br'; }; just to make sure that the value is yes, and not 1 or true or something like that. Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I will try that, thanks, I did just try to echo the $row['AddEditAdmin'] results, as I do in the query section and in that it does return YES or NO like I expect, but when I tried to echo it down in the page where I need to use it guess what..no echo... am I cutting my query off somewhere? could it be the while statement
Re: [PHP] Re: can a session be used in a query?
On Wed, Jan 7, 2009 at 4:13 PM, Terion Miller webdev.ter...@gmail.comwrote: On Wed, Jan 7, 2009 at 4:10 PM, Frank Stanovcak blindspot...@comcast.netwrote: Terion Miller webdev.ter...@gmail.com wrote in message news:37405f850901071354p7abd0aa8i7c96cf69c81fa...@mail.gmail.com... $result=mysql_query($query) or die('Queryproblem: ' . mysql_error() . 'br /Executedquery: ' . $query); if (mysql_num_rows($result) = '1'){ while ($row = mysql_fetch_assoc($result)){ echo $row['AddEditAdmin']; //to print out the value of column 'var1' for each record } }else{ echo 'No records found.'; } ? anyone have ideas for me, the session user is working, and I need to use it in the query to pull only that users data I also on the login page where I set that session all set it to = $UserName but when I try and use that in the query UserName = $UserName I get an undefined variable error... Really trying but not quite getting it... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well I am def. further along, the query is working, I can echo fields in the $row and get the results but when I try and use this: ?php if ($row['AddEditAdmin'] == 'YES') { ? to sort out what menu items to load it just doesn't do its job. I would say do this to see if what is in the return is what you are expecting foreach($row as $key=$value){ echo $key , ': ' , $value , 'br'; }; just to make sure that the value is yes, and not 1 or true or something like that. Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I will try that, thanks, I did just try to echo the $row['AddEditAdmin'] results, as I do in the query section and in that it does return YES or NO like I expect, but when I tried to echo it down in the page where I need to use it guess what..no echo... am I cutting my query off somewhere? could it be the while statement Ok tried that and got *Warning*: Invalid argument supplied for foreach()
[PHP] Help with a Search Function
Hey Everyone, been steaming right along for a couple days but now I'm stuck on writing a search function, could you all take a look at it and see what it could be, I will mark the line throwing the error in red, I did try just commenting out that line and searching for a record by OrderID that I know is there but it does not return anything , I am trying to search several tables in one db: Code: ?php session_start(); include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] 'OK' ){ header (Location: LogOut.php); } if (isset($_GET['AdminID']) !empty($_GET['AdminID'])){ $AdminID = $_GET['AdminID']; } elseif (isset($_POST['AdminID']) !empty($_POST['AdminID'])){ $AdminID = $_POST['AdminID']; } else { header (Location: LogOut.php); } $query = SELECT SearchWorkOrder FROM admin WHERE AdminID='$AdminID'; $result = mysql_query ($query); $row = mysql_fetch_object ($result); if ($row-SearchWorkOrder == NO) { header (Location: Welcome.php?AdminID='.$_SESSION[AdminLogin]'msg=Sorry, you do not have access to that page.); } if (isset($_POST['WorkOrderID'])) {$WorkOrderID = $_POST['WorkOrderID'];} else {$WorkOrderID = '';} if (isset($_POST['WorkOrderName'])) {$WorkOrderName = $_POST['WorkOrderName'];} else {$WorkOrderName = '';} if (isset($_POST['CustomerName'])) {$CustomerName = $_POST['CustomerName'];} else {$CustomerName = '';} if (isset($_POST['CustomerEmail'])) {$CustomerEmail = $_POST['CustomerEmail'];} else {$CustomerEmail = '';} if (isset($_POST['SalesRep'])) {$SalesRep = $_POST['SalesRep'];} else {$SalesRep = '';} if (isset($_POST['SalesRepEmail'])) {$SalesRepEmail = $_POST['SalesRepEmail'];} else {$SalesRepEmail = '';} if (isset($_POST['SortBy'])) {$SortBy = $_POST['SortBy'];} else {$SortBy = 'WorkOrderID DESC';} if (isset($_POST['Page'])) {$Page = $_POST['Page'];} else {$Page = 1;} $PerPage = 30; $StartPage = ($Page - 1) * $PerPage; $OrderID = ''; // All Orders $sql = SELECT WorkOrderID FROM workorders WHERE WorkOrderID '' ; if (!empty($WorkOrderName)) { $sql .= AND Advertiser LIKE '%. $WorkOrderName .%' ; } if (!empty($WorkOrderID)) { $sql .= AND WorkOrderID LIKE '%. $WorkOrderID .%' ; } $result = mysql_query ($sql); while ($row = mysql_fetch_object ($result)) { $OrderID = $OrderID ., . $row-WorkOrderID; } // Work Orders if (!empty($CustomerName) || !empty($CustomerEmail) || !empty($SalesRep) || !empty($SalesRepEmail)) { $sql = SELECT WorkOrderID FROM workorderform WHERE WorkOrderID'' ; if (!empty($CustomerName)) { $sql .= AND Advertiser LIKE '%. $CustomerName .%' ; } if (!empty($CustomerEmail)) { $sql .= AND AdContactEmail LIKE '%. $CustomerEmail .%' ; } if (!empty($SalesRep)) { $sql .= AND Salesperson LIKE '%. $SalesRep .%' ; } if (!empty($SalesRepEmail)) { $sql .= AND SalespersonEmail LIKE '%. $SalesRepEmail .%' ; } $result = mysql_query ($sql); while ($row = mysql_fetch_object ($result)) { $OrderID = $OrderID ., . $row-WorkOrderID; } } // Homescape Builder Profile if (!empty($CustomerName) || !empty($CustomerEmail) || !empty($SalesRep) || !empty($SalesRepEmail)) { $sql = SELECT WorkOrderID FROM hs_builder_profile WHERE WorkOrderID'' ; if (!empty($CustomerName)) { $sql .= AND OrganizationName LIKE '%. $CustomerName .%' ; } if (!empty($CustomerEmail)) { $sql .= AND LeadEmail LIKE '%. $CustomerEmail .%' ; } if (!empty($SalesRep)) { $sql .= AND Salesperson LIKE '%. $SalesRep .%' ; } if (!empty($SalesRepEmail)) { $sql .= AND SalespersonEmail LIKE '%. $SalesRepEmail .%' ; } $result = mysql_query ($sql); while ($row = mysql_fetch_object ($result)) { $OrderID = $OrderID ., . $row-WorkOrderID; } } // Homescape Builder Spec Home if (!empty($CustomerName) || !empty($SalesRep) || !empty($SalesRepEmail)) { $sql = SELECT WorkOrderID FROM hs_spec_home WHERE WorkOrderID'' ; if (!empty($CustomerName)) { $sql .= AND CommunityName LIKE '%. $CustomerName .%' ; } if (!empty($SalesRep)) { $sql .= AND Salesperson LIKE '%. $SalesRep .%' ; } if (!empty($SalesRepEmail)) { $sql .= AND SalespersonEmail LIKE '%. $SalesRepEmail .%' ; } $result = mysql_query ($sql); while ($row = mysql_fetch_object ($result)) { $OrderID = $OrderID ., . $row-WorkOrderID; } } // Planet Discover Coupon if (!empty($CustomerName) || !empty($SalesRep) || !empty($SalesRepEmail)) { $sql = SELECT WorkOrderID FROM pd_coupon WHERE WorkOrderID'' ; if (!empty($CustomerName)) { $sql .= AND BusinessName LIKE '%.
[PHP] still can't get a login with session working ... is there another way to mask the url parameter?
Still this won't pass the session to the next page is there a way to pass parameters in the url but mask them? maybe that would be easier, since I do have code that works passing the adminID on the url ... can a parameter be hashed after the fact? I tried echo-ing the fields on the next page and they are not passing... my code that still doesn't work: ?php // start session session_start(); include(inc/dbconn_open.php) ; $errs = error_reporting ('E_ALL'); if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT * FROM admin WHERE UserName ='$UserName' and Password ='$Password' or die(mysql_error()); $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = $row['AdminID']; header (Location: Main.php); } else { $msg = Invalid Login; } } ?
[PHP] error flashing on redirect
I am working on the login script I have been troubling over, and when I hit submit it throws an error and even though I have error reporting E_All on because its on a redirect or something I can see the error for only a split second so I can't catch it to figure it out (does this make sense?) how would I go about making that error visible long enough to read? Thanks Guys! Terion
[PHP] header modify errors
I am working from home today and getting this error with my copy of my project: *Warning*: Cannot modify header information - headers already sent by (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31) in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on line *3* *Warning*: Cannot modify header information - headers already sent by (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31) in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on line *4* Could not connect to the database. I have set my php.ini file output_buffering to ON it was off (read in a past post that will fix this error--but it did not) I also set session.cache_limiter = to nothing it was set to nocache Any other things I'm missing? Thanks Terion
Re: [PHP] Re: header modify errors
On Mon, Dec 15, 2008 at 11:37 AM, Jim Lucas li...@cmsws.com wrote: Jay Moore wrote: Terion Miller wrote: I am working from home today and getting this error with my copy of my project: *Warning*: Cannot modify header information - headers already sent by (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31) in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on line *3* *Warning*: Cannot modify header information - headers already sent by (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31) in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on line *4* Could not connect to the database. I have set my php.ini file output_buffering to ON it was off (read in a past post that will fix this error--but it did not) I also set session.cache_limiter = to nothing it was set to nocache Any other things I'm missing? Thanks Terion What's on/around line 31 in Welcome.php? J Jay. I agree with your thought process. Why not fix the warning instead of hiding it. But that isn't what the OP is asking for. I think the OP understands why it is giving this warning, but is looking for a way to not display the error. Sounds like his production environment is setup to where it does not display the warning. So, he wants his newly installed test machine to match what the production is doing. Correct me if I'm wrong Terion. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well If there is a problem with the script and that is why its giving the warning I would want to fix that, I just figured the php.ini file on the live server at the office is different from the one i have on my home xampp install and I am not allowed access to the php.ini on the server at work, I just tried getting it to compare it to my own. I have to go check to see about the .htaccess file, I need to read up on these, like what is the difference and if you have one do you need the other? .htaccess is for directory control yes? If that is the case there is none in the directory I have this project in. I just stopped and restarted my xampp and that didn't work either...should I make a .htaccess file for this directory to over ride whatever setting is preventing the headers from loading? Thanks guys Terion
Re: [PHP] Re: header modify errors
On Mon, Dec 15, 2008 at 11:29 AM, Jay Moore jaymo...@accu-com.com wrote: Terion Miller wrote: I am working from home today and getting this error with my copy of my project: *Warning*: Cannot modify header information - headers already sent by (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31) in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on line *3* *Warning*: Cannot modify header information - headers already sent by (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31) in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on line *4* Could not connect to the database. I have set my php.ini file output_buffering to ON it was off (read in a past post that will fix this error--but it did not) I also set session.cache_limiter = to nothing it was set to nocache Any other things I'm missing? Thanks Terion What's on/around line 31 in Welcome.php? J Line 32-36 are: ?php If (!empty($msg)){ echo div class=\Error\. $msg ./divBRBR; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Poll of Sorts: Application Frameworks--Zend, Cake etc
On Thu, Dec 11, 2008 at 4:25 PM, Colin Guthrie gm...@colin.guthr.ie wrote: 'Twas brillig, and Terion Miller at 11/12/08 14:56 did gyre and gimble: Hey Everyone, I am wondering if using a framework such as one of these may make my life easier, which do any of you use and what has been your experience with the learning curve of them? I just put Cake on my local server, basically I want to know which is easiest? LOL... Personally I'm a ZF fan, but each to their own. Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the responses, CakePhp was seemingly very easy for me to catch on to and get started in (which means its super super easy folks) unfortunately when I got to the viewing of my files (pretty important) I couldn't get the IIS (yep I know sucks) to work with it, and I installed a mod_rewrite.dll for IIS and everything along with setting it to Cakes pretty urls and removing the htdocs, but then it just kept resolving all urls to the root ... no matter what I changed the path to, and no matter if I set it only to that directory...so by end of day yesterday I downloaded the zend and will attempt to see what I can do with it, I want off this windows box but that isn't going to happen anytime soon ...sigh... Terion
[PHP] Resource ID# 5 and Resource id #5 8561 errors....help
Hey there, okay I ran into these and need some tips, pointers etc... First I was getting the Resource ID#5 error with this query: $query=SELECT * FROM importimages WHERE Category='Obits'; $result = mysql_query($query); so then I read how mysql_query returns a resource, so I tried this: $query = SELECT * FROM importimages WHERE Category='Obits' ; $result = mysql_query ($query); $arr = mysql_fetch_row($result); $result2 = $arr[0]; echo ($result2); when I echo the result2 I get: 8561 --no idea what the heck that is the next line is this and its giving me probs: while ($row = mysql_fetch_object ($result)) --that is what it was orginally but it is not pulling anything out of the db, which led me to echo the query results (see I am learning finally) so I could see if it really wasn't doing anything and well its not...and if I try to make an array and then fetch it as an object it tells me invalid, I think I'm confused about how to make an object out of an array (if that is what I want to do) this is pulling images from a db. Thanks guys! Terion
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 4:02 PM, Daniel P. Brown daniel.br...@parasane.netwrote: On Fri, Dec 12, 2008 at 16:54, Terion Miller webdev.ter...@gmail.com wrote: $query = SELECT * FROM importimages WHERE Category='Obits' ; $result = mysql_query ($query); $arr = mysql_fetch_row($result); $result2 = $arr[0]; echo ($result2); Try this to get yourself started: ?php $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($row = mysql_fetch_array($result)) { foreach($row as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } ? NOTE: You shouldn't need stripslashes(), but it's put there just for backwards-compatibility in case you're on an older (or poorly-configured) installation. -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php Thanks Daniel that did get me further, am I now to build an object from the array, or take off one of the array to make an object, your snippet did grab the names of the images and print them to the page but then I get stuck where the page is trying to get the property of a non-object ..so I guess im asking is a possible to turn an array into an object? or in this case separate objects?
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 4:52 PM, Terion Miller webdev.ter...@gmail.comwrote: On Fri, Dec 12, 2008 at 4:02 PM, Daniel P. Brown daniel.br...@parasane.net wrote: On Fri, Dec 12, 2008 at 16:54, Terion Miller webdev.ter...@gmail.com wrote: $query = SELECT * FROM importimages WHERE Category='Obits' ; $result = mysql_query ($query); $arr = mysql_fetch_row($result); $result2 = $arr[0]; echo ($result2); Try this to get yourself started: ?php $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__.well I changed it to - .mysql_error()); while($row = mysql_fetch_array($result)) { foreach($row as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } ? NOTE: You shouldn't need stripslashes(), but it's put there just for backwards-compatibility in case you're on an older (or poorly-configured) installation. -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php Thanks Daniel that did get me further, am I now to build an object from the array, or take off one of the array to make an object, your snippet did grab the names of the images and print them to the page but then I get stuck where the page is trying to get the property of a non-object ..so I guess im asking is a possible to turn an array into an object? or in this case separate objects? Well I did some changes and I must be learning because although I have the same error I don't have new ones... so now the code is like this: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FileName = $object-Image; ---This is the line that is telling me it is trying to get the properties of a non-object
Re: [PHP] Resource ID# 5 and Resource id #5 8561 errors....help
On Fri, Dec 12, 2008 at 5:08 PM, Daniel P. Brown daniel.br...@parasane.netwrote: On Fri, Dec 12, 2008 at 18:03, Terion Miller webdev.ter...@gmail.com wrote: Well I did some changes and I must be learning because although I have the same error I don't have new ones... so now the code is like this: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FileName = $object-Image; ---This is the line that is telling me it is trying to get the properties of a non-object That's because you're calling that as an object using OOP standards, where I gave you procedural code. To interface with my code, just call it as: ?php // other code here while($row = mysql_fetch_array($result)) { echo $row['Image'].br /\n; // If `Image` is the column name. } // code continues ? -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php Here is the full chunk: $sql = SELECT * FROM `importimages` WHERE `Category` = 'Obits'; $result = mysql_query($sql) or die(Error in .__FILE__.:.__LINE__. - .mysql_error()); while($object = mysql_fetch_object($result)) { foreach($object as $k = $v) { echo stripslashes($k).: .stripslashes($v).br /\n; } } $FilePath = output/WebImagesHiRes/; $BackupPath = output/WebImagesHiRes/backup/; $FileName = $object-Image; //because it is going to process an image doesnt that make it oop? $FileName = str_replace(/, , $FileName); $FileName = str_replace(.jpg, , $FileName); Well its late friday afternoon here, I'm ready to break away from my desk...maybe on monday I will be able to get it working (right now our obit pics in the online paper are not getting posted...oops) Thanks folks yawn LEts call it a weekend wt terion
[PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc
Hey Everyone, I am wondering if using a framework such as one of these may make my life easier, which do any of you use and what has been your experience with the learning curve of them? I just put Cake on my local server, basically I want to know which is easiest? LOL... Terion
Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc
On Thu, Dec 11, 2008 at 9:22 AM, Bastien Koert [EMAIL PROTECTED] wrote: On Thu, Dec 11, 2008 at 10:15 AM, Eric Butera [EMAIL PROTECTED]wrote: On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller [EMAIL PROTECTED] wrote: Hey Everyone, I am wondering if using a framework such as one of these may make my life easier, which do any of you use and what has been your experience with the learning curve of them? I just put Cake on my local server, basically I want to know which is easiest? LOL... Terion Define easiest. What is it that you need to code? If you mean cookie cutter sites that have been done a million times with minimal flexibility... :) I'm in the same boat as you though. I don't know which one meets the needs I have the best. There's stuff like cake which is really easy to start up, then there's stuff like symphony that will let you do anything, but you really have to work at it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php There are definite learning curves when picking these up. symfony and ZF have the largest because they either do more (symfony) or are designed to be used piecemeal (ZF) CodeIgnitor is one of the easiest ones to start using with Cake not far behind -- Bastien Cat, the other other white meat I'll have to check out CodeIgnitor, I can say that with my limited ability I have set up Cake and made a db connection within 10 mins, and I'm not entirely confused and frustrated yet so thats a good sign ...lol terion
[PHP] how to not show login info in the url ...what am I looking for?
So I have this login information passing parameters in the url to the next page (this is on a intranet app) which I thought was no big deal until a wise crack graphics guy decided to hack it because he could by changing the ?adminID= until he got one that worked...he didn't do anything except alert my boss so now I have to hide this info how does one do this? Once again I am not a programmer just inherited the joband the code... Here is the login page code: ?php if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else {$UserName = '';} if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else {$Password = '';} $msg = ''; if (!empty($UserName)) { $sql = SELECT * FROM admin WHERE UserName='$UserName' and Password='$Password'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); If (mysql_num_rows($result) 0) { $_SESSION['AdminLogin'] = OK; header (Location: Main.php?AdminID=. $row-AdminID); } else { $msg = Invalid Login; } } ? HTML HEAD TITLEWork Order System - Administrative Section/TITLE LINK REL=STYLESHEET HREF=inc/style.css script language=JavaScript !-- function leftTrim(sString) { while (sString.substring(0,1) == ' ') { sString = sString.substring(1, sString.length); } return sString; } function chkData1(objForm) { objForm.UserName.value = leftTrim(objForm.UserName.value); if (objForm.UserName.value.length == 0) { alert(Please enter your User Name.); objForm.Email.focus(); return false; } objForm.Password.value = leftTrim(objForm.Password.value); if (objForm.Password.value.length == 0) { alert(Please enter a your Password.); objForm.Password.focus(); objForm.Password.select(); return false; } return true; } //-- /script /HEAD BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 TABLE WIDTH=780 BORDER=0 CELLSPACING=0 CELLPADDING=0 TR TDnbsp;/TD /TR TR TD ALIGN=CENTERBWork Order System - Administrative Section/BBRBR/TD /TR TR TD ?php If (!empty($msg)){ echo div class=\cl_Error\. $msg ./div; } ? form name=form1 method=post action=Index.php onSubmit=return chkData1(this) TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=center bgcolor=#CC TR TD HEIGHT=22div class=admin_MainUsername:/div/TD TD HEIGHT=22 INPUT TYPE=text NAME=UserName/TD /TR TR TDdiv class=admin_MainPassword:/div/TD TDINPUT TYPE=password NAME=Password/TD /TR TR TD colspan=2 align=centerINPUT TYPE=submit VALUE=Login /TD /TR /TABLE /form BR Thanks guys and gals!
Re: [PHP] Will not report errors what can I do
On Fri, Dec 5, 2008 at 12:08 PM, Robert Cummings [EMAIL PROTECTED]wrote: On Fri, 2008-12-05 at 10:40 -0500, tedd wrote: At 3:19 PM + 12/5/08, [EMAIL PROTECTED] wrote: $result = mysql_query($query) or die(report($query,__LINE__ ,__FILE__)); // to show dB errors == function report($query, $line, $file) { echo($query . 'br' .$line . 'br/' . $file . 'br/' . mysql_error()); } This does two things: 1) It tells where the error took place (line/file); 2) and it provides a single place in my entire project to turn-off dB error reporting -- all I have to do is comment out a single line. I did this, briefly, but got tired of typing __LINE__, __FILE__ so much. That's what I call common code -- I type it once and after that it's all cut/paste. I have entire libraries of routines that I've used before -- I just cut/paste them into the new stuff as needed. Even many of the variable names remain the same so it becomes more a job of assembly more than typing. I have to say... for what he's trying to achieve, I cheat and extract the file and line number via debug_backtrace(). Indeed, it is annoying to type the same thing over and over :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks to everyone you really helped and I got that page error showing and fixed and whew...on to my next problems! I am starting a new discussion thread because I want to see what people think between using Javascript form validation or php form validation on php pagesstay tuned and much thanks! Terion
[PHP] Poll of sorts: Javascript Form validation or PHP
I have a huge form to validate and wonder which is better javascript validation or php, the page is a php page, I actually put js validation on it but then it stopped working (stopped inserting into the db) not sure if that had anything to do with it What does everyone prefer? Terion who is actually finally learning stuff to her surprise!!
[PHP] SQL syntax?
Hi I am having problems (yep me again) with my sql, I have looked and tried different things (ASC, DESC, etc) but it same error: Here is the error: 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 'ORDER BY StartDate DESC' at line 2 --and the actual line the code is on is line 21 not 2 so that is weird...and I had a comma between DESC and the field but nothing Code: $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql .= ORDER BY StartDate DESC; could it be the AS, I copied that from another code--- I am trying to make a report from the tableHere is my full script: ?php include(../inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] 'OK' ){ header (Location: LogOut.php); } $query = SELECT WorkOrderID, Advertiser, AccountNum, Impressions, AdSize, StartDate, EndDate, CPM, OnlineDate FROM workorderform; $result = mysql_query ($query) or die(mysql_error()); $row = mysql_fetch_object ($result); if ($row-UserReport == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql .= ORDER BY StartDate DESC; $export = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_object ($result); $fields = mysql_num_fields($export); $header = ; $value = ; $data = ; for ($i = 0; $i $fields; $i++) { $header .= mysql_field_name($export, $i) . \t; } while($row2 = mysql_fetch_row($export)) { $line = ''; foreach($row2 as $value) { if ((!isset($value)) OR ($value == )) { $value = \t; } else { $value = str_replace('', '', $value); $value = '' . $value . '' . \t; } $line .= $value; } $data .= trim($line).\n; } $data = str_replace(\r,,$data); if ($data == ) { $data = \n(0) Records Found!\n; } header(Content-type: application/x-msdownload); header(Content-Disposition: attachment; filename=AdDates_Report.xls); header(Pragma: no-cache); header(Expires: 0); print $header\n$data; ?
Re: [PHP] SQL syntax?
On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED]wrote: $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql .= ORDER BY StartDate DESC; You forgot the tables, plus you have an extra comma after CPM_Rate. well I changed it to: $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID, DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= workorderform.Advertiser AS Advertiser_Name,workorderform.AccountNum AS Account_Number, workorderform.Impressions AS Ad_Impressions, ; $sql .= workorderform.AdSize AS Ad_Size, workorderform.CPM AS CPM_Rate ; $sql .= ORDER BY StartDate DESC; and got the same error
Re: [PHP] SQL syntax?
ah...I also though it was because I didn't have a statement like where adsize = adsize or something but I tried that and got the same error I have been getting ... 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 'FROM workorderform, WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC' at line 2 and why does it keep saying line 2... here is the snippet as it is now: $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql.= FROM workorderform, ; $sql .= WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC; On Fri, Dec 5, 2008 at 4:14 PM, Allan Arguelles [EMAIL PROTECTED]wrote: Umm.. I meant you need to put $sql .= FROM workorderform ; between these: $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql .= ORDER BY StartDate DESC; :) Terion Miller wrote: On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL PROTECTED]wrote: $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql .= ORDER BY StartDate DESC; You forgot the tables, plus you have an extra comma after CPM_Rate. well I changed it to: $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID, DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= workorderform.Advertiser AS Advertiser_Name,workorderform.AccountNum AS Account_Number, workorderform.Impressions AS Ad_Impressions, ; $sql .= workorderform.AdSize AS Ad_Size, workorderform.CPM AS CPM_Rate ; $sql .= ORDER BY StartDate DESC; and got the same error
Re: [PHP] SQL syntax?
Excellent Allan thanks so much, sometimes I think php is causing me blindness!! Terion On Fri, Dec 5, 2008 at 4:26 PM, Allan Arguelles [EMAIL PROTECTED]wrote: Try this: $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate ; $sql.= FROM workorderform ; $sql .= WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC; I just removed extra commas from CPM_Rate and workorderform Terion Miller wrote: ah...I also though it was because I didn't have a statement like where adsize = adsize or something but I tried that and got the same error I have been getting ... 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 'FROM workorderform, WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC' at line 2 and why does it keep saying line 2... here is the snippet as it is now: $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql.= FROM workorderform, ; $sql .= WHERE WorkOrderID = WorkOrderID ORDER BY StartDate DESC; On Fri, Dec 5, 2008 at 4:14 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL PROTECTED]wrote: Umm.. I meant you need to put $sql .= FROM workorderform ; between these: $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql .= ORDER BY StartDate DESC; :) Terion Miller wrote: On Fri, Dec 5, 2008 at 3:57 PM, Allan Arguelles [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]wrote: $sql = SELECT WorkOrderID AS Work_Order_ID, DATE_FORMAT(StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= Advertiser AS Advertiser_Name,AccountNum AS Account_Number, Impressions AS Ad_Impressions, ; $sql .= AdSize AS Ad_Size, CPM AS CPM_Rate, ; $sql .= ORDER BY StartDate DESC; You forgot the tables, plus you have an extra comma after CPM_Rate. well I changed it to: $sql = SELECT workorderform.WorkOrderID AS Work_Order_ID, DATE_FORMAT(workorderform.StartDate, '%b. %e, %Y %l:%i %p') AS Start_Date, DATE_FORMAT(workorderform.EndDate, '%b. %e, %Y %l:%i %p') AS End_Date, ; $sql .= workorderform.Advertiser AS Advertiser_Name,workorderform.AccountNum AS Account_Number, workorderform.Impressions AS Ad_Impressions, ; $sql .= workorderform.AdSize AS Ad_Size, workorderform.CPM AS CPM_Rate ; $sql .= ORDER BY StartDate DESC; and got the same error
[PHP] Will not report errors what can I do
Hey everyone I am still fighting the same problem that my script isn't working and its not reporting errors, when you click to view the work order it doesn't do anything, I have all kinds of error reporting turned on but nothing, do I have them syntax wrong? ?php include(inc/dbconn_open.php); error_reporting(E_ALL); ini_set('display_errors', '1'); error_log(errors.txt); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] 'OK' ){ header (Location: LogOut.php); } if (isset($_GET['AdminID']) !empty($_GET['AdminID'])){ $AdminID = $_GET['AdminID']; } else { header (Location: LogOut.php); } $query = SELECT ViewAllWorkOrders FROM admin WHERE AdminID='$AdminID'; $result = mysql_query ($query); $row = mysql_fetch_object ($result); if ($row-ViewProjects == NO) { header (Location: Welcome.php?AdminID=$AdminIDmsg=Sorry, you do not have access to that page.); } if (isset($_GET['WorkOrderID'])) {$WorkOrderID = $_GET['WorkOrderID'];} else {$WorkOrderID = '';} if (isset($_GET['ReturnPage'])) {$ReturnPage = $_GET['ReturnPage'];} else {$ReturnPage = 'Welcome.php';} $sql = SELECT FormName FROM workorders WHERE WorkOrderID='$WorkOrderID'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); if (mysql_num_rows($result) 0) { if ($row-FormName == WorkOrder) { header (Location: ViewWorkOrder.php?AdminID=$AdminIDWorkOrderID=$WorkOrderIDReturnPage=$ReturnPage); }elseif ($row-FormName == PD_Coupon) { header (Location: ViewPD_Coupon.php?AdminID=$AdminIDWorkOrderID=$WorkOrderIDReturnPage=$ReturnPage); }elseif ($row-FormName == PD_TextAd) { header (Location: ViewPD_TextAd.php?AdminID=$AdminIDWorkOrderID=$WorkOrderIDReturnPage=$ReturnPage); }elseif ($row-FormName == PD_Enhanced) { header (Location: ViewPD_Enhanced.php?AdminID=$AdminIDWorkOrderID=$WorkOrderIDReturnPage=$ReturnPage); }elseif ($row-FormName == HS_Builder) { header (Location: ViewHomescape_Builder.php?AdminID=$AdminIDWorkOrderID=$WorkOrderIDReturnPage=$ReturnPage); }elseif ($row-FormName == HS_SpecHome) { header (Location: ViewHomescape_SpecHome.php?AdminID=$AdminIDWorkOrderID=$WorkOrderIDReturnPage=$ReturnPage); } else { header (Location: Welcome.php?AdminID=$AdminIDmsg=Nothing works Does it); } } else { header (Location: Welcome.php?AdminID=$AdminIDmsg=Nothing Works..g); } ?
[PHP] question about corrupt db?
could a corrupt db make php pages stop functioning? My pages no longer go anywhere, I went back found the original scripts and still it didn't fix the problem (thought I had messed the code up) so it has to be something external of the code its doing this locally on my box and on the live server. thanks terion
Re: [PHP] question about corrupt db?
On Mon, Dec 1, 2008 at 3:12 PM, Micah Gersten [EMAIL PROTECTED] wrote: Terion Miller wrote: could a corrupt db make php pages stop functioning? My pages no longer go anywhere, I went back found the original scripts and still it didn't fix the problem (thought I had messed the code up) so it has to be something external of the code its doing this locally on my box and on the live server. thanks terion Have you checked the PHP error logs? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com I put this: ini_set('error_reporting', E_ALL); ini_set('display_errors', true); in the top of the pages but no errors are showing
Re: [PHP] question about corrupt db?
On Mon, Dec 1, 2008 at 3:40 PM, Wolf [EMAIL PROTECTED] wrote: -Original Message- From: Terion Miller [EMAIL PROTECTED] Sent: Monday, December 01, 2008 4:23 PM To: Micah Gersten [EMAIL PROTECTED] Cc: PHP General php-general@lists.php.net Subject: Re: [PHP] question about corrupt db? On Mon, Dec 1, 2008 at 3:12 PM, Micah Gersten [EMAIL PROTECTED] wrote: Terion Miller wrote: could a corrupt db make php pages stop functioning? My pages no longer go anywhere, I went back found the original scripts and still it didn't fix the problem (thought I had messed the code up) so it has to be something external of the code its doing this locally on my box and on the live server. thanks terion Have you checked the PHP error logs? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com I put this: ini_set('error_reporting', E_ALL); ini_set('display_errors', true); in the top of the pages but no errors are showing -- Then that answer would be no You need to actually look at your error logs as if the server is set up right it won,'t allow ini bypasses. Wolf I can't find any error logs, I've looked in the inetpub folder, the php folder the IIS services admin
Re: [PHP] question about corrupt db?
On Mon, Dec 1, 2008 at 4:20 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: On Mon, 2008-12-01 at 15:53 -0600, Terion Miller wrote: On Mon, Dec 1, 2008 at 3:40 PM, Wolf [EMAIL PROTECTED] wrote: -Original Message- From: Terion Miller [EMAIL PROTECTED] Sent: Monday, December 01, 2008 4:23 PM To: Micah Gersten [EMAIL PROTECTED] Cc: PHP General php-general@lists.php.net Subject: Re: [PHP] question about corrupt db? On Mon, Dec 1, 2008 at 3:12 PM, Micah Gersten [EMAIL PROTECTED] wrote: Terion Miller wrote: could a corrupt db make php pages stop functioning? My pages no longer go anywhere, I went back found the original scripts and still it didn't fix the problem (thought I had messed the code up) so it has to be something external of the code its doing this locally on my box and on the live server. thanks terion Have you checked the PHP error logs? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com I put this: ini_set('error_reporting', E_ALL); ini_set('display_errors', true); in the top of the pages but no errors are showing -- Then that answer would be no You need to actually look at your error logs as if the server is set up right it won,'t allow ini bypasses. Wolf I can't find any error logs, I've looked in the inetpub folder, the php folder the IIS services admin IIS has an option that lets you view the websites you have set up (I believe you can get to it from right-clicking My Computer and selecting Manage.) Select the site you are having problems with, and view the properties for it. One of the tabs (I forget which exactly) tells you where the error logs are for this site. Ash www.ashleysheridan.co.uk wow not there either, is it possible the person in this job before me just removed the logs and the servers capability to log? like there is no usr/bin/log file or anything like that (went to the apache site) and in the IIS install I went thru everything and can't find a thing about error logs...OMG pulling out my hair.
[PHP] Help with understanding an error
Can anyone help explain what I need to do to fix this: Error: *Warning*: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in * C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php* on line *57* *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result resource in *C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php* on line * 65 Code: line 57: $row = mysql_fetch_object ($result); line 65: if (mysql_num_rows($result) == 0) { ? *
Re: [PHP] Help with understanding an error
I added an echo and got this: Query failed: Unknown column 'WorkOrderNumber' in 'field list' Actual query: but the actual query is blank and as I have stated before when I have had questions on this list, I am NOT a php programmer, just learning and inherited a job with tons of php already in place, so please save all the snarky comments about how stupid I am, I don't need them, lists are supposed to be helpful not hurtful. On Mon, Nov 24, 2008 at 11:32 AM, Wolf [EMAIL PROTECTED] wrote: Terion Miller [EMAIL PROTECTED] wrote: Can anyone help explain what I need to do to fix this: Error: *Warning*: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in * C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php* on line *57* *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result resource in *C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php* on line * 65 Code: line 57: $row = mysql_fetch_object ($result); line 65: if (mysql_num_rows($result) == 0) { ? * STFW as Google has the answer.. But... you need to actually provide MORE of the code, since the error pretty much tells you that you don't have a connection to your database. Not a PHP issue really. Wolf
Re: [PHP] Help with understanding an error
this was the code I posted that accidentally only went to Wolf: what does STFW mean? ?php include(inc/dbconn_open.php); if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] 'OK' ){ ? script language=javascript window.close(); /script ?php exit(); } if (isset($_POST['AdminID'])){ $AdminID = $_POST['AdminID']; } elseif (isset($_GET['AdminID'])){ $AdminID = $_GET['AdminID']; } else { ? script language=javascript window.close(); /script ?php exit(); } if (isset($_POST['WorkOrderID'])){ $WorkOrderID = $_POST['WorkOrderID']; } elseif (isset($_GET['WorkOrderID'])){ $WorkOrderID = $_GET['WorkOrderID']; } else { ? script language=javascript window.close(); /script ?php exit(); } if (isset($_POST['ReturnPage'])){ $ReturnPage = $_POST['ReturnPage']; } elseif (isset($_GET['ReturnPage'])){ $ReturnPage = $_GET['ReturnPage']; } else { $ReturnPage = Welcome.php; } $sql = SELECT WorkOrderID, CreatedDate, IONumber, OrderType, WorkOrderNumber, Advertiser, AccountNum, Address, City, ; $sql .= State, Zip, Phone, Fax, ContactName, URL, AdvertisingAgency, ClickThru, Impressions, AdSize, ; $sql .= DATE_FORMAT(StartDate, '%m/%e/%Y') AS StartDates, DATE_FORMAT(EndDate, '%m/%e/%Y') AS EndDates, CPM, FlatRate, ; $sql .= IncludeSites, Package, Matrix, DATE_FORMAT(MatrixDate, '%m/%e/%Y') AS MatrixDates, Salesperson, SalespersonID, ; $sql .= SalespersonEmail, SalespersonExt, NameCampaign, SpecialInstructions, AdContactName, AdContactPhone, AdContactEmail, ; $sql .= Artwork, DATE_FORMAT(PrintDate, '%m/%e/%Y') AS PrintDates, ElectronicAd, EmailProof, ; $sql .= DATE_FORMAT(ProofDate, '%m/%e/%Y') AS ProofDates, ArtInstructions, Focus, BannerSize, BannerSizeOther, BannerType, ; $sql .= BannerTypeOther, ExtraImage1, ExtraImage1Desc, ExtraImage2, ExtraImage2Desc, ExtraImage3, ExtraImage3Desc, ; $sql .= ExtraImage4, ExtraImage4Desc, ExtraImage5, ExtraImage5Desc FROM workorderform WHERE WorkOrderID='$WorkOrderID'; $result = mysql_query ($sql); $row = mysql_fetch_object ($result); $sql2 = SELECT Date_FORMAT(CreatedDate,'%m/%e/%Y %h:%i %p') AS OrderDate, Location, WorkOrderName, Status FROM workorders ; $sql2 .= WHERE WorkOrderID='$WorkOrderID'; $result2 = mysql_query ($sql2); $row2 = mysql_fetch_object ($result2); if (mysql_num_rows($result) == 0) { ? script language=javascript window.close(); /script ?php exit(); } ? On Mon, Nov 24, 2008 at 11:32 AM, Wolf [EMAIL PROTECTED] wrote: Terion Miller [EMAIL PROTECTED] wrote: Can anyone help explain what I need to do to fix this: Error: *Warning*: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in * C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php* on line *57* *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result resource in *C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php* on line * 65 Code: line 57: $row = mysql_fetch_object ($result); line 65: if (mysql_num_rows($result) == 0) { ? * STFW as Google has the answer.. But... you need to actually provide MORE of the code, since the error pretty much tells you that you don't have a connection to your database. Not a PHP issue really. Wolf
Re: [PHP] Invalid Arguements
I currently have it like this: select name=BannerSize option value=0Select a Banner Size/option option value=728x90728x90 - Leaderboard/option option value=160x600160x600 - Skyscraper/option option value=300x250300x250 - Square/option option value=88x31-300x25088x31 and 300x250/option option value=120x240120x240/option option value=940x30940x30 - Pencil Ad/option /select but your saying it should be select name=BannerSize[] On Wed, Nov 19, 2008 at 8:14 PM, Jim Lucas [EMAIL PROTECTED] wrote: Terion Miller wrote: Actually it did at one point have bannersize[#] # being the numbers 1-however many were there I've since gotten rid of that and made it a select. and gotten rid of the implode all together because it wouldn't work in either case and the more I read the more confused I got. Terion Why don't you show us a snippet of code that is the form page for this. Let us see what you are trying to describe to us. Even if you switched it to a SELECT .../SELECT the name attribute still needs to contain the brackets if you expect to pass more then one SELECT field in the same form. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare
[PHP] Invalid Arguements
I am still getting the Invalid arguement error on this implode: if (isset($_POST['BannerSize'])){$BannerSize = implode(',',$_POST['BannerSize']);} else {$BannerSize = ;} I have moved the ',', from the beginning to the end of the statement and nothing works is there any other way to do this, basically there is a form and the people entering work orders can select different sized banners they need, which goes into the db as text so...argh...
Re: [PHP] Invalid Arguements
I've been trying to catch on to php on the fly, I started with Cold fusion years ago then did asp for a long time, for some reason php gives me problems, it doesn't at all seem intuitive to me or even logical for that matterguess I'm just used to the easy stuff. when I use the var_dump as suggested I get: *Parse error*: syntax error, unexpected '' in * C:\Inetpub\wwwroot\WorkOrderSystem\WorkOrder.php* on line *136* On Wed, Nov 19, 2008 at 8:51 AM, Boyd, Todd M. [EMAIL PROTECTED] wrote: Taking this back on-list... From: Terion Miller [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 19, 2008 8:44 AM To: Boyd, Todd M. Subject: Re: [PHP] Invalid Arguements I don't know how to run is_array this is the problem I'm a designer that is stuck doing a coders job On Wed, Nov 19, 2008 at 8:36 AM, Boyd, Todd M. [EMAIL PROTECTED] wrote: -Original Message- From: Terion Miller [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 19, 2008 8:32 AM To: php-general@lists.php.net Subject: [PHP] Invalid Arguements I am still getting the Invalid arguement error on this implode: if (isset($_POST['BannerSize'])){$BannerSize = implode(',',$_POST['BannerSize']);} else {$BannerSize = ;} I have moved the ',', from the beginning to the end of the statement and nothing works is there any other way to do this, basically there is a form and the people entering work orders can select different sized banners they need, which goes into the db as text so...argh... Take the time to read what people have suggested. I seem to remember people asking you if you had run is_array() on your so-called array. Well, if you didn't, and it's NOT an array, and therefore will NOT work with implode(), then feel free to facepalm ahead of time. --- ?php if(is_array($myvar)) { $newvar = implode(',', $myvar); } else { echo 'Cats and dogs living together! Mass hysteria!'; } ? I believe something to that effect was posted, with fully intact code, on the list. Not to be rude, but if you're tasked with PHP programming and you don't understand what it is to run a function, you should probably bone up on procedural fundamentals and PHP in general before you go much further... or you're going to SERIOUSLY screw something up and be at a loss as to what you did (or how to fix it). Again--I'm not trying to be rude. I am giving honest advice. http://www.w3schools.com/php Hope this helps (sincerely), // Todd
Re: [PHP] Invalid Arguements
Actually it did at one point have bannersize[#] # being the numbers 1-however many were there I've since gotten rid of that and made it a select. and gotten rid of the implode all together because it wouldn't work in either case and the more I read the more confused I got. Terion On Wed, Nov 19, 2008 at 1:59 PM, Nathan Rixham [EMAIL PROTECTED] wrote: Ashley Sheridan wrote: On Wed, 2008-11-19 at 08:31 -0600, Terion Miller wrote: I am still getting the Invalid arguement error on this implode: if (isset($_POST['BannerSize'])){$BannerSize = implode(',',$_POST['BannerSize']);} else {$BannerSize = ;} I have moved the ',', from the beginning to the end of the statement and nothing works is there any other way to do this, basically there is a form and the people entering work orders can select different sized banners they need, which goes into the db as text so...argh... As mentioned quite a few times before, you cannot change the order of the arguments, it will not work! There is no indicator in the PHP Manual page for this function either that says you can switch the orders, so I'm not sure why you think you can. Ash www.ashleysheridan.co.uk have you read the manual mate? Note: implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments. this one is a simple one though, his form is wrong (as stated before); html form should have multiple: input type=xxx name=BannerSize[] ... / so that an array is passed, but it'll only have: input type=xxx name=BannerSize ... / thus passing no array to $_POST['BannerSize'], thus implode won't work as neither param is an array. :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php