Jump to content

mem0ri

Members
  • Posts

    110
  • Joined

  • Last visited

    Never

Everything posted by mem0ri

  1. Just a quick look...but it appears that your "else" statement is nested within your while statement...which means it will only run if you get a return row from the database... ...that would be your problem.
  2. [code]          // Display all gig listings to page. $result = @mysql_query('SELECT cid, name, tel, email, bandname, contactid FROM contactinfo, bandname'); if(!$result) {     exit ('<p>Error performing query ' . mysql_error() . '</p>'); }                      [/code] Warning: I'm also newish to PHP and MySQL... ...but...is appears that the problem might be in your query to select the list. It doesn't seem like you're qualifying to which bandname a contact-info will associate itself. Something like... SELECT cid, name, tel, email, bandname, contactid FROM contactinfo, bandname WHERE cid = contactid; ...seems to make more sense to me. That way you're qualifying how each row from the two tables is related...
  3. Ouch...talk about a simple overlook...thank you so much greycap! I would have stared blankly at the code forever...hah. And yes...greycap is also right that I'm doing concatenation with a "$form .=" ...it's a lot easier than doin' "$form = $form."
  4. EDIT: SOLVED Been sittin' for ages tryin' to figure out what's wrong... ...page comes up...but when the "submit" button is pressed, nothing happens...nothing at all...Funny thing is, it all worked fine until I cut and paste the HTML into PHP. [code] <?php     require("MySQLQueries.php");     require("FormsandHeaders.php");     include("FCKeditor/fckeditor.php");          $edited = @$_POST['Submit'];     $toedit = @$_GET['edit'];     $pagename = "PageAdmin.php";          $header = getHeader();     echo($header); ?> <table align="center" width="780"><tr> <td>     <?php         $menu = getMenu();         echo($menu);     ?> </td> <td align="right">          <?php         if($toedit)         {             echo("<form action=\"PageAdmin.php\" method=\"post\">");             $retrieved = fetchSingle("content","$pagename","page","db");             $retrieved = $retrieved['text'];             $oFCKeditor = new FCKeditor('PageEntry');             $oFCKeditor->BasePath = '/FCKeditor/';             $oFCKeditor->Value = $retrieved;             $editor = $oFCKeditor->Create();             echo("<input name=\"Submit\" type=\"button\" value=\"Submit Page\"></form>");         }         else if($edited)         {             $author = "Admin";             $update = editValue("content","text,author","'$edited','$author'","page = '$pagename'","schaeffer");             echo($update);         }         else         {             $retrieved = fetchSingle("content","$pagename","page","db");             $retrieved = $retrieved['text'];                          $form1="<table><tr><td>";             $form1.=$retrieved;             $form1.="</td></tr>";             $form1.="<tr><td align=\"right\"><a href=\"$pagename?edit=yes\">Edit</td></tr>";             $form1.="</table>";             echo($form1);         }     ?> [/code]
  5. [!--quoteo(post=352641:date=Mar 7 2006, 02:06 PM:name=stevesmename)--][div class=\'quotetop\']QUOTE(stevesmename @ Mar 7 2006, 02:06 PM) [snapback]352641[/snapback][/div][div class=\'quotemain\'][!--quotec--] When using check boxes in forms on HTML Pages -- I send the data over to PHP and then request to pull the data from the checkbox -- BUT if the checkbox wasn't selected, then a notice displays on the screen saying variable not defined. How do I get this notice to not display. I know I can shut it off in php.ini settings, but I rather not do this way - I like to debug my errors. -- Thanks for your help. [/quote] You can also put an @ in front of your variable...as in: $info = @$_POST['checkbox2'];
  6. Try something like: [code] $query="SELECT * FROM table"; $qresult = mysql_query($query); if(mysql_num_rows <= 0) { --Code to Use if no results-- } else { --Code to Use if results-- } [/code]
  7. [!--quoteo(post=352105:date=Mar 6 2006, 09:09 AM:name=Aaron Korr)--][div class=\'quotetop\']QUOTE(Aaron Korr @ Mar 6 2006, 09:09 AM) [snapback]352105[/snapback][/div][div class=\'quotemain\'][!--quotec--] I'm pretty new to PHP and I'm wondering how I would sort a table using 2 different fields, for example sorting by age and then by name. [/quote] Sorting tables works best through SQL statements if you're using a database. $query = "SELECT * FROM users ORDER BY name ASC, age DESC"; $qresult = mysql_query($query); while($row = mysql_fetch_array($qresult)) { qarray[] = $row; } ...qarray will then be an array filled with your sorted values from the database. The SQL statement sorts first by name in ascending (ASC) order...or A-Z...and then by age in descending (DESC) order...or oldest to youngest.
  8. [!--quoteo(post=352113:date=Mar 6 2006, 09:29 AM:name=billy61)--][div class=\'quotetop\']QUOTE(billy61 @ Mar 6 2006, 09:29 AM) [snapback]352113[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]$query2  = "SELECT * FROM comments WHERE article_id='" . $id . "'";[/code] [/quote] Looks like you've got too many quotes in your SQL statement... [code] $query2 = "SELECT * FROM comments WHERE article_id=' '.$id.' '"; [/code] Dunno why you're puttin' whitespace in front of and after the $id...I'd just do: [code] $query2 = "SELECT * FROM comments WHERE article_id=$id"; [/code]
  9. Right...my big question is on the: function myFunction($y = $x) part... ...because the global hasn't been declared within the function yet...and is operating as the default value of information passed into the variable... ...additional...slightly related question...let's say I have: function myFunction($y = $x, $b = "string", $n = 1) ...and I want to call the function with somethin' like a myFunction("string")...where it will only change the default value of $b...leaving $y and $n alone... ...basically...is there a way to explicitly address to which value a function call sends its arguments?
  10. The question is purely academic at this point...but I have a question about the valid use of a global variable and whether the following would work or error out: $x = 1; function myFunction($y = $x) { global $x; do stuff }
×
×
  • Create New...

Important Information

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