Re: [PHP] Re: stupid error, please kick me (and send me a solution)

2002-06-03 Thread leco

Do not use double kotes here. 
$link_glob = \mysql_connect(\'$host_glob\', \'$un_glob\',
\'$pw_glob\')\;

mysql_connect is a function.

Regards,

Laercio Fortes




Citando Jason Soza [EMAIL PROTECTED]:

 If this is truly the code you\'re using, you\'re missing the closing 
 curly-brace after the else statement. I.e. this:
 } else {
   echo \font size=+1Your Information has successfully been 
 entered into the database!/fontbr\;
 
 Should be this:
 } else {
   echo \font size=+1Your Information has successfully been 
 entered into the database!/fontbr\;
}
 
 HTH,
 Jason Soza
 
 - Original Message -
 From: Jule Slootbeek [EMAIL PROTECTED]
 Date: Monday, June 3, 2002 2:09 pm
 Subject: stupid error, please kick me (and send me a solution)
 
  Hey guys,
  i\'m getting this error with the following sql script using php:
  --error--
  Warning: Supplied argument is not a valid MySQL-Link resource in 
  /var/www/phpquiz/register_user.php on line 12
  --error--
  
  --script--
  $link_glob = \mysql_connect(\'$host_glob\', \'$un_glob\', \'$pw_glob\')\;
  $query = \INSERT INTO user values(\'0\', \'$fname\', \'$lname\', 
  \'$email\', 
  \'$username\', PASSWORD(\'$password\')\;
  $result = mysql_db_query(\'$db_glob\', \'$query\', 
  $link_glob\');  if (!$result) {
  echo \font size=+1Your Information 
  could not be entered into the database, 
  Please contact the 
  href=mailto:$webmasterwebmaster./fontbrbr\ . mysql_errno() 
  . 
  \: \ . mysql_error() . \brbr\;
  } else {
  echo \font size=+1Your Information 
 has 
  successfully been entered into the 
  database!/fontbr\;
  
  -- 
  Jule Slootbeek  
  [EMAIL PROTECTED] 
  
  http://blindtheory.cjb.net 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 



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




Re: [PHP] Re: stupid error, please kick me (and send me a solution)

2002-06-03 Thread Jule Slootbeek

[EMAIL PROTECTED] wrote:
 Do not use double kotes here. 
 $link_glob = \mysql_connect(\'$host_glob\', \'$un_glob\',
 \'$pw_glob\')\;
 
 mysql_connect is a function.
 
 Regards,
 
 Laercio Fortes
 
 
 
 
 Citando Jason Soza [EMAIL PROTECTED]:
 
 
If this is truly the code you\'re using, you\'re missing the closing 
curly-brace after the else statement. I.e. this:
} else {
  echo \font size=+1Your Information has successfully been 
entered into the database!/fontbr\;

Should be this:
} else {
  echo \font size=+1Your Information has successfully been 
entered into the database!/fontbr\;
   }

HTH,
Jason Soza

- Original Message -
From: Jule Slootbeek [EMAIL PROTECTED]
Date: Monday, June 3, 2002 2:09 pm
Subject: stupid error, please kick me (and send me a solution)


Hey guys,
i\'m getting this error with the following sql script using php:
--error--
Warning: Supplied argument is not a valid MySQL-Link resource in 
/var/www/phpquiz/register_user.php on line 12
--error--

--script--
$link_glob = \mysql_connect(\'$host_glob\', \'$un_glob\', \'$pw_glob\')\;
$query = \INSERT INTO user values(\'0\', \'$fname\', \'$lname\', 
\'$email\', 
\'$username\', PASSWORD(\'$password\')\;
 $result = mysql_db_query(\'$db_glob\', \'$query\', 
$link_glob\');   if (!$result) {
 echo \font size=+1Your Information 
could not be entered into the database, 
Please contact the 
href=mailto:$webmasterwebmaster./fontbrbr\ . mysql_errno() 
. 
\: \ . mysql_error() . \brbr\;
 } else {
 echo \font size=+1Your Information 

has 

successfully been entered into the 
database!/fontbr\;

-- 
Jule Slootbeek   
[EMAIL PROTECTED] 

http://blindtheory.cjb.net 


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



 
 
 

changing that line to this:
$link_glob = mysql_connect($host_glob, $un_glob, $pw_glob);
doesn't make any difference...
i still get the error..
could it be my setup?
the $link_glob var is in globals.inc.php and i use this through 
require('globals.inc.php'); which has worked great in the past...
the other two lines.
Now:
$query = INSERT INTO user values('0', '$fname', '$lname', '$email',
'$username', PASSWORD('$password');
$result = mysql_db_query($db_glob, $query, $link_gob);
are in register_user.php in which the first line is 
require('globals.inc.php');

I've used this method in the past also, and i've never experienced 
problems with it...
  thanks,
Jule
-- 
Jule Slootbeek  
[EMAIL PROTECTED] 

http://blindtheory.cjb.net 



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




Re: [PHP] Re: stupid error, please kick me (and send me a solution)

2002-06-03 Thread Philip Olson

Are you sure this is the correct file?  This is full 
of syntax errors, you should be getting parse errors.

A few tips:

 a) Don't post to multiple lists.  This is a PHP issue, 
not MySQL.  Hopefully this will end the mysql list
thread.

 b) Don't use mysql_db_query() as it is deprecated.  See:
  http://www.php.net/mysql_db_query
Use mysql_select_db() and mysql_query() instead.

 c) Be 100% this is right file, or if this (what you gave 
us) is the exact code in that file.  I doubt it is.

 d) If an error is on line 12, tell us what line #11-13 are.

 e) While developing, put error_reporting(E_ALL); on top 
of your script.

 f) Don't fully rely on syntax highlighting of your text 
editor as it will never be perfect.

To narrow down the error, try this format:

?php

  if (!$conn = mysql_connect($host, $username, $password)) {
print Could not connect:  . mysql_error();
exit;
  }

  if (!mysql_select_db($dbname)) {
print Could not select DB  . mysql_error();
exit;
  }

  $sql = Your SQL goes here;
  
  if (!$result = mysql_query($sql)) {
print Could not run query ($sql) :  . mysql_error();
exit;
  }

  print Thank you for submitting the data, we got it;

?

Basically, we are checking if these functions return 
false.  If they do, an error will be sent and the 
script will exit.  Instead of using exit each time, 
you may want to implement your own db error management 
so if a db error occurs you load a static page or 
your webmaster email or whatever.  But the above should 
narrow down your error and is a good start.

The original reason you got this error is, I assume, that 
you treated $link_glob as a simple string.  Other replies 
discussed this a bit.  Lastly:

  print $foo;   // sexy
  print $foo; // not as sexy but will work (eww)
  print '$foo'; // literally prints a string $foo and 
// not the value of $foo.  bad.

Read/study this tutorial on using strings:
  http://www.zend.com/zend/tut/using-strings.php

Good luck, you'll get the hang of it soon :)

Regards,
Philip Olson


On Mon, 3 Jun 2002, Jule Slootbeek wrote:

 Jule Slootbeek wrote:
  G r e g L a w r i e wrote:
  
  It would also appear you are missing a closing ) at the end of the
  '$query=...' line. You have two opening backets and only one closing.
 
  Greg
 
  -Original Message-
  From: Bruce Lewis [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, 4 June 2002 7:50
  To: [EMAIL PROTECTED]; mysql; php-general
  Subject: Re: stupid error, please kick me (and send me a solution)
 
 
  Your missing your closing } at the end of the else statement.
 
 
  - Original Message -
  From: Jule Slootbeek [EMAIL PROTECTED]
  To: mysql [EMAIL PROTECTED]; php-general
  [EMAIL PROTECTED]
  Sent: Monday, June 03, 2002 5:09 PM
  Subject: stupid error, please kick me (and send me a solution)
 
 
 
  Hey guys,
  i'm getting this error with the following sql script using php:
  --error--
  Warning: Supplied argument is not a valid MySQL-Link resource in
  /var/www/phpquiz/register_user.php on line 12
  --error--
 
  --script--
  $link_glob = mysql_connect('$host_glob', '$un_glob', '$pw_glob');
  $query = INSERT INTO user values('0', '$fname', '$lname', '$email',
  '$username', PASSWORD('$password');
  $result = mysql_db_query('$db_glob', '$query', $link_glob');
  if (!$result) {
  echo font size=+1Your Information could not be entered into the
 
 
  database,
 
  Please contact the a
  href=mailto:$webmasterwebmaster/a./fontbrbr . mysql_errno() .
  :  . mysql_error() . brbr;
  } else {
  echo font size=+1Your Information has successfully been entered into
 
 
  the
 
  database!/fontbr;
 
  -- 
  Jule Slootbeek
  [EMAIL PROTECTED]
 
  http://blindtheory.cjb.net
 
 
 
  -
  Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
  To request this thread, e-mail [EMAIL PROTECTED]
  To unsubscribe, e-mail
 
 
  [EMAIL PROTECTED]
 
  Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 
 
 
 
 
 
  -
  Before posting, please check:
 http://www.mysql.com/manual.php   (the manual)
 http://lists.mysql.com/   (the list archive)
 
  To request this thread, e-mail [EMAIL PROTECTED]
  To unsubscribe, e-mail
  [EMAIL PROTECTED]
  Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 
  
  $query = INSERT INTO user values('0', '$fname', '$lname', '$email', 
  '$username', PASSWORD('$password');
  
  that should be all closed shouldn't it?
  my text editor colors code, and it doesn't show any mistakes..
  thanks though
  Jule
  
 well it didn't fix it, but still thanks,
 
 Jule
 
 
 
 -- 
 Jule Slootbeek
 [EMAIL PROTECTED] 
 
 http://blindtheory.cjb.net 
   
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To