[PHP] call to undefined function: mysql_connect

2002-07-27 Thread lfindle

Hi.

I'm running PHP 4.2.1 & MySQL 3.23. I'm getting the error message "Call to
undefined function: mysql_connect()" when I try to use it in my code. If
anyone has any ideas as to why this might be happening, I'd be appreciative.



Thanks!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] New to PHP- Form Validation Logic/Design Question

2002-06-01 Thread lfindle

 
I am *very* new to PHP & am trying to write a tool where a user can add books to a 
library MySQL database. 

The user fills out an HTML form. I do some form validation & if the form entries are 
ok, I need to run some SQL queries using the form variables.

I have the HTML form posting back to itself to do the error checking. The part I am 
unclear on is how to handle the SQL queries. 

I was thinking that if the user filled out the form correctly, I could redirect to a 
new php script/page to handle the SQL queries. The problem is that if I do so, I do 
not have access to the form variables that I need. The only way I know to pass 
variables to a new script is through a form posting & it doesn't make sense to have 2 
form postings for one form.

I suppose I could run the SQL queries from the same script although when I use my 
below logic, the SQL queries print out underneath the HTML form which looks pretty bad.

I was thinking that if I approach it this way, I need some way to loop back through 
all my "if" statements so that I could catch the last one only ($REQUEST_METHOD == 
"post" && $validated == "yes")
and therefore wouldn't get the HTML form again. I tried putting a while(true){ } loop 
around the entire thing which resulted in printing my HTML table infinity times :)

I included a pseudocode form of my logic here & my actual code below.

If anyone has any thoughts, suggestions, ideas, or comments, I'd really appreciate it! 
Also, is there a good IRC channel for php users?

Laura
[EMAIL PROTECTED]
Instant Messenger: lefindley

if ($REQUEST_METHOD != "POST"){

   include("./form.html");

} else if ($REQUEST_METHOD == "POST" && $validated == "no"){

   perform error checking
   display errors at top of page
   include("./form.html");

} else if ($REQUEST_METHOD == "POST" && $validated
== "yes") {

**here is where I need to run the SQL queries**
 
}

--

Book title cannot be blank!";
   }
   if ($author == "") {
  $err .= "Author cannot be left blank!";   }
   if ($author != ""){
   if (!ereg('[a-zA-Z]', $author)){
$err .= "Author name must be " .
  "letters!";
  }
   }
   if ($price == ""){
  $err .= "Price cannot be left blank!";
   }
   if ($price != ""){
  if (!is_numeric($price)){
 $err .=  "Price must be numbers!";
  }
   }
   if ($isbn == ""){
  $err .= "ISBN cannot be left blank!";
   }
   if ($isbn != ""){
  if (!is_numeric($isbn)){
 $err .= "ISBN must be numbers!";

  }
   }
   if ($num_copies != ""){
  if (!is_numeric($num_copies)){
 $err .= "# of copies must be ".
" numbers!";
  }
   }
   if ($checked_out != ""){
  if (!is_numeric($checked_out)){
 $err .= "# of checked out copies must be " .

  if ($checked_out != ""){
  if (!is_numeric($checked_out)){
 $err .= "# of checked out copies must be " .
  " numbers!";
  }
   }
   if (is_numeric($checked_out) && is_numeric($num_copies)){
  if ($checked_out > $num_copies){
 $err .= "# of copies checked out cannot " .
 "exceed number of copies in library!";
  }
   }
   include("./form.html");

   if ($err == ""){
  $validated = "yes";
  break;
}

print "Validated: $validated";
  }  // end of else if


if ($REQUEST_METHOD == "POST" && $validated == "yes"){

// if user has correctly filled out the form, I 
// need to run some MySQL queries using the form // variables - not sure if it is best 
to do this // on the same page or redirect to another.

// if i run the SQL queries from the same page,
// i need to be able to not display the HTML form

// if i redirect to another script, I need a way
// to pass the form variables

  print "do some SQL stuff";
   }




?>








-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php