Re: [PHP-DB] I can't solve the error in the code

2007-01-27 Thread Alexander
thank you. That appears to have solved it.
  - Original Message - 
  From: Santiago Zarate 
  To: Alexander 
  Sent: Saturday, January 27, 2007 7:26 PM
  Subject: Re: [PHP-DB] I can't solve the error in the code


 if(!input) { // an error here... should be !$input or even 
if(!add_to_table( $_REQUEST['picture'], $_REQUEST['thumbnail'] ))
echo 'Error\!';
  }


  Also you're calling a function that isn't created yet according with your 
code, also i dont see 
  Also in your function add_to_table, has some errors too... like you're NOT 
calling a db conection from it... and i guess it should... since i have to do 
it with classes... when it comes to functions... you should too... 

  for your write_form code... i think youre using your code wrong...

   also check here: http://ve.php.net/manual/en/function.print.php


  there might be more errors... lñemme do a fast debug here: 



  [EMAIL PROTECTED]:~$ nano php.php
  [EMAIL PROTECTED]:~$ php -f php.php

  Parse error: syntax error, unexpected $end in /home/santiago/php.php on line 
69


  that means there's an missing } somewhere... if youre on linux... install 
php cli and use it to debug... (Or use bluefish that is way more easy) and 
quanta to build your code... if you're on windows... well set your ini to 
E_ALL, then choose eitther using console for PHP and load the file... or use 
your browser and run the script until it runs fine without errors... if you're 
using a shared host... create a error function that logs everything into a 
file... might save you lots of time... 


  2007/1/27, Alexander [EMAIL PROTECTED]:
I'm writing a script for uploading into a database urls for a picture and 
its thumbnail, but for some reason when I test it out the page doesn't load, 
and not even the errors appear. Please help, here's the code: 

html

body

?php

 $user = userone;
 $pass = password;
 $database = mydatabase;

 $link = mysql_connect(localhost, $user, $pass); 
if(!$link) {
  echo 'Error in linking';
}

 $db = mysql_select_db($database, $link);
   if(!$db) {
 echo 'Error in DB';
   }
   else {

 if ( !empty( $_REQUEST['picture'] )  !empty( 
$_REQUEST['thumbnail'] ) ) {
   $input = add_to_table( $_REQUEST['picture'], 
$_REQUEST['thumbnail'] );
 if(!input) { 
   echo 'Error\!';
 }
 else {
  echo 'Data enter successfully\!';
}
  }
 else {
   write_form();
   }

   function add_to_table( $picture, $thumbnail ) { 
 $picture = mysql_real_escape_string($picture);
 $thumbnail = mysql_real_escape_string($thumbnail);

 $insert = 'INSERT INTO domains ( picture, thumbnail ) values( 
$picture, $thumbnail )'; 
 $indata = mysql_query( $insert, $link );

   }

   function write_form() {
 print EOF

form method='post' action='{$_SERVER['PHP_SELF']}' 

pEnter url of large picture: input type='text' 
name='picture' /

pEnter url of thumbnail: input type='text' name='thumbnail' 
/ 

 echo 'pinput type='submit' value='Add to Database' /'

 /form;
FORM;
   }
?

/body

/html




Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Stephen Johnson
My first thought is that your values in your insert statement are not in
quotes..

 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';

Should be 

$insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture,
$thumbnail)';

Hope that helps.

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/ 
?


 From: Alexander [EMAIL PROTECTED]
 Date: Sat, 27 Jan 2007 19:55:17 -0600
 To: PHP-DB php-db@lists.php.net
 Subject: [PHP-DB] Am I missing something?
 
 I fixed my code and it shows up fine now. It says it supposedly enters the
 data when I input the fields but when I check the MySQL database, the info
 isn't there.
 
 Here's the fixed code if you wish to test it:
 
 html
 
 body
 
 ?php
 
   function add_to_table( $picture, $thumbnail ) {
  $picture = mysql_real_escape_string($picture);
  $thumbnail = mysql_real_escape_string($thumbnail);
 
  $user = user;
  $pass = password;
  $database = mydata;
 
$link = mysql_connect(localhost, $user, $pass);
 if(!$link) {
   echo 'Error in linking';
 }
 
  $db = mysql_select_db($database, $link);
 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';
  $indata = mysql_query( $insert, $link );
 
 
 }
 
 function write_form() {
  echo form method='post' action='{$_SERVER['PHP_SELF']}';
 
  echo pEnter url of large picture: input type='text'
 name='picture' /;
 
  echo pEnter url of thumbnail: input type='text'
 name='thumbnail' /;
 
  echo pinput type='submit' value='Add to Database' /;
 
  echo /form;
 }
 
  if ( !empty( $_REQUEST['picture'] )  !empty(
 $_REQUEST['thumbnail'] ) ) {
$input = add_to_table( $_REQUEST['picture'],
 $_REQUEST['thumbnail'] );
  if(!input) {
echo 'Error\!';
  }
  else {
   echo 'Data enter successfully\!';
   $idreturn = mysql_insert_id($input);
   echo 'Image inserted to ID ' . $idreturn;
 }
   }
  else {
write_form();
}
 
 ?
 
 /body
 
 /html 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Alexander

No change.

I echod my insert statement and got : INSERT INTO domains ( picture, 
thumbnail ) values( $picture, $thumbnail )


excatly like that. Shouldn't the values echo as what should be inserted into 
the database?


- Original Message - 
From: Stephen Johnson [EMAIL PROTECTED]

To: Alexander [EMAIL PROTECTED]; PHP-DB php-db@lists.php.net
Sent: Saturday, January 27, 2007 8:01 PM
Subject: Re: [PHP-DB] Am I missing something?



My first thought is that your values in your insert statement are not in
quotes..



 $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
$picture, $thumbnail )';


Should be

$insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture,
$thumbnail)';

Hope that helps.

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/
?



From: Alexander [EMAIL PROTECTED]
Date: Sat, 27 Jan 2007 19:55:17 -0600
To: PHP-DB php-db@lists.php.net
Subject: [PHP-DB] Am I missing something?

I fixed my code and it shows up fine now. It says it supposedly enters 
the
data when I input the fields but when I check the MySQL database, the 
info

isn't there.

Here's the fixed code if you wish to test it:

html

body

?php

  function add_to_table( $picture, $thumbnail ) {
 $picture = mysql_real_escape_string($picture);
 $thumbnail = mysql_real_escape_string($thumbnail);

 $user = user;
 $pass = password;
 $database = mydata;

   $link = mysql_connect(localhost, $user, $pass);
if(!$link) {
  echo 'Error in linking';
}

 $db = mysql_select_db($database, $link);

 $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
$picture, $thumbnail )';
 $indata = mysql_query( $insert, $link );


}

function write_form() {
 echo form method='post' action='{$_SERVER['PHP_SELF']}';

 echo pEnter url of large picture: input type='text'
name='picture' /;

 echo pEnter url of thumbnail: input type='text'
name='thumbnail' /;

 echo pinput type='submit' value='Add to Database' /;

 echo /form;
}

 if ( !empty( $_REQUEST['picture'] )  !empty(
$_REQUEST['thumbnail'] ) ) {
   $input = add_to_table( $_REQUEST['picture'],
$_REQUEST['thumbnail'] );
 if(!input) {
   echo 'Error\!';
 }
 else {
  echo 'Data enter successfully\!';
  $idreturn = mysql_insert_id($input);
  echo 'Image inserted to ID ' . $idreturn;
}
  }
 else {
   write_form();
   }

?

/body

/html

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






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



Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Alexander

Alright, this may be the problem:

Fatal error: Call to undefined function mysql_real_escape_string() in 
C:\apache2triad\htdocs\gallery.php on line 10


which is refering to :

$picture = mysql_real_escape_string($picture);


/* never again use direct code from an example in a book, there's always an 
error */


- Original Message - 
From: Alexander [EMAIL PROTECTED]

To: PHP-DB php-db@lists.php.net
Sent: Saturday, January 27, 2007 8:13 PM
Subject: Re: [PHP-DB] Am I missing something?



No change.

I echod my insert statement and got : INSERT INTO domains ( picture, 
thumbnail ) values( $picture, $thumbnail )


excatly like that. Shouldn't the values echo as what should be inserted 
into the database?


- Original Message - 
From: Stephen Johnson [EMAIL PROTECTED]

To: Alexander [EMAIL PROTECTED]; PHP-DB php-db@lists.php.net
Sent: Saturday, January 27, 2007 8:01 PM
Subject: Re: [PHP-DB] Am I missing something?



My first thought is that your values in your insert statement are not in
quotes..



 $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
$picture, $thumbnail )';


Should be

$insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture,
$thumbnail)';

Hope that helps.

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/
?



From: Alexander [EMAIL PROTECTED]
Date: Sat, 27 Jan 2007 19:55:17 -0600
To: PHP-DB php-db@lists.php.net
Subject: [PHP-DB] Am I missing something?

I fixed my code and it shows up fine now. It says it supposedly enters 
the
data when I input the fields but when I check the MySQL database, the 
info

isn't there.

Here's the fixed code if you wish to test it:

html

body

?php

  function add_to_table( $picture, $thumbnail ) {
 $picture = mysql_real_escape_string($picture);
 $thumbnail = mysql_real_escape_string($thumbnail);

 $user = user;
 $pass = password;
 $database = mydata;

   $link = mysql_connect(localhost, $user, $pass);
if(!$link) {
  echo 'Error in linking';
}

 $db = mysql_select_db($database, $link);

 $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
$picture, $thumbnail )';
 $indata = mysql_query( $insert, $link );


}

function write_form() {
 echo form method='post' action='{$_SERVER['PHP_SELF']}';

 echo pEnter url of large picture: input type='text'
name='picture' /;

 echo pEnter url of thumbnail: input type='text'
name='thumbnail' /;

 echo pinput type='submit' value='Add to Database' /;

 echo /form;
}

 if ( !empty( $_REQUEST['picture'] )  !empty(
$_REQUEST['thumbnail'] ) ) {
   $input = add_to_table( $_REQUEST['picture'],
$_REQUEST['thumbnail'] );
 if(!input) {
   echo 'Error\!';
 }
 else {
  echo 'Data enter successfully\!';
  $idreturn = mysql_insert_id($input);
  echo 'Image inserted to ID ' . $idreturn;
}
  }
 else {
   write_form();
   }

?

/body

/html

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






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



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



Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Stephen Johnson
What version of php are using?  It is odd that mysql_real_escape_string is
undefined..

Alternately you could addslashes...
Hope this helps

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/ 
?


 From: Alexander [EMAIL PROTECTED]
 Date: Sat, 27 Jan 2007 20:17:54 -0600
 To: PHP-DB php-db@lists.php.net
 Subject: Re: [PHP-DB] Am I missing something?
 
 Alright, this may be the problem:
 
 Fatal error: Call to undefined function mysql_real_escape_string() in
 C:\apache2triad\htdocs\gallery.php on line 10
 
 which is refering to :
 
 $picture = mysql_real_escape_string($picture);
 
 
 /* never again use direct code from an example in a book, there's always an
 error */
 
 - Original Message -
 From: Alexander [EMAIL PROTECTED]
 To: PHP-DB php-db@lists.php.net
 Sent: Saturday, January 27, 2007 8:13 PM
 Subject: Re: [PHP-DB] Am I missing something?
 
 
 No change.
 
 I echod my insert statement and got : INSERT INTO domains ( picture,
 thumbnail ) values( $picture, $thumbnail )
 
 excatly like that. Shouldn't the values echo as what should be inserted
 into the database?
 
 - Original Message -
 From: Stephen Johnson [EMAIL PROTECTED]
 To: Alexander [EMAIL PROTECTED]; PHP-DB php-db@lists.php.net
 Sent: Saturday, January 27, 2007 8:01 PM
 Subject: Re: [PHP-DB] Am I missing something?
 
 
 My first thought is that your values in your insert statement are not in
 quotes..
 
 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';
 
 Should be
 
 $insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture,
 $thumbnail)';
 
 Hope that helps.
 
 ?php
 /*
 
 Stephen Johnson c | eh
 The Lone Coder
 
 http://www.ouradoptionblog.com
 Join our journey of adoption
 
 http://www.thelonecoder.com
 [EMAIL PROTECTED]
 
 continuing the struggle against bad code
 
 */
 ?
 
 
 From: Alexander [EMAIL PROTECTED]
 Date: Sat, 27 Jan 2007 19:55:17 -0600
 To: PHP-DB php-db@lists.php.net
 Subject: [PHP-DB] Am I missing something?
 
 I fixed my code and it shows up fine now. It says it supposedly enters
 the
 data when I input the fields but when I check the MySQL database, the
 info
 isn't there.
 
 Here's the fixed code if you wish to test it:
 
 html
 
 body
 
 ?php
 
   function add_to_table( $picture, $thumbnail ) {
  $picture = mysql_real_escape_string($picture);
  $thumbnail = mysql_real_escape_string($thumbnail);
 
  $user = user;
  $pass = password;
  $database = mydata;
 
$link = mysql_connect(localhost, $user, $pass);
 if(!$link) {
   echo 'Error in linking';
 }
 
  $db = mysql_select_db($database, $link);
 
  $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
 $picture, $thumbnail )';
  $indata = mysql_query( $insert, $link );
 
 
 }
 
 function write_form() {
  echo form method='post' action='{$_SERVER['PHP_SELF']}';
 
  echo pEnter url of large picture: input type='text'
 name='picture' /;
 
  echo pEnter url of thumbnail: input type='text'
 name='thumbnail' /;
 
  echo pinput type='submit' value='Add to Database' /;
 
  echo /form;
 }
 
  if ( !empty( $_REQUEST['picture'] )  !empty(
 $_REQUEST['thumbnail'] ) ) {
$input = add_to_table( $_REQUEST['picture'],
 $_REQUEST['thumbnail'] );
  if(!input) {
echo 'Error\!';
  }
  else {
   echo 'Data enter successfully\!';
   $idreturn = mysql_insert_id($input);
   echo 'Image inserted to ID ' . $idreturn;
 }
   }
  else {
write_form();
}
 
 ?
 
 /body
 
 /html
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Alexander
I'm using PHP 5, I'm running this off of my personal laptop so I downloaded 
ApacheTriad2
- Original Message - 
From: Stephen Johnson [EMAIL PROTECTED]

To: Alexander [EMAIL PROTECTED]; PHP-DB php-db@lists.php.net
Sent: Saturday, January 27, 2007 8:24 PM
Subject: Re: [PHP-DB] Am I missing something?



What version of php are using?  It is odd that mysql_real_escape_string is
undefined..

Alternately you could addslashes...
Hope this helps

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/
?



From: Alexander [EMAIL PROTECTED]
Date: Sat, 27 Jan 2007 20:17:54 -0600
To: PHP-DB php-db@lists.php.net
Subject: Re: [PHP-DB] Am I missing something?

Alright, this may be the problem:

Fatal error: Call to undefined function mysql_real_escape_string() in
C:\apache2triad\htdocs\gallery.php on line 10

which is refering to :

$picture = mysql_real_escape_string($picture);


/* never again use direct code from an example in a book, there's always 
an

error */

- Original Message -
From: Alexander [EMAIL PROTECTED]
To: PHP-DB php-db@lists.php.net
Sent: Saturday, January 27, 2007 8:13 PM
Subject: Re: [PHP-DB] Am I missing something?



No change.

I echod my insert statement and got : INSERT INTO domains ( picture,
thumbnail ) values( $picture, $thumbnail )

excatly like that. Shouldn't the values echo as what should be inserted
into the database?

- Original Message -
From: Stephen Johnson [EMAIL PROTECTED]
To: Alexander [EMAIL PROTECTED]; PHP-DB php-db@lists.php.net
Sent: Saturday, January 27, 2007 8:01 PM
Subject: Re: [PHP-DB] Am I missing something?


My first thought is that your values in your insert statement are not 
in

quotes..



 $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
$picture, $thumbnail )';


Should be

$insert = 'INSERT INTO domains ( picture, thumbnail ) values( 
$picture,

$thumbnail)';

Hope that helps.

?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.ouradoptionblog.com
Join our journey of adoption

http://www.thelonecoder.com
[EMAIL PROTECTED]

continuing the struggle against bad code

*/
?



From: Alexander [EMAIL PROTECTED]
Date: Sat, 27 Jan 2007 19:55:17 -0600
To: PHP-DB php-db@lists.php.net
Subject: [PHP-DB] Am I missing something?

I fixed my code and it shows up fine now. It says it supposedly enters
the
data when I input the fields but when I check the MySQL database, the
info
isn't there.

Here's the fixed code if you wish to test it:

html

body

?php

  function add_to_table( $picture, $thumbnail ) {
 $picture = mysql_real_escape_string($picture);
 $thumbnail = mysql_real_escape_string($thumbnail);

 $user = user;
 $pass = password;
 $database = mydata;

   $link = mysql_connect(localhost, $user, $pass);
if(!$link) {
  echo 'Error in linking';
}

 $db = mysql_select_db($database, $link);

 $insert = 'INSERT INTO domains ( picture, thumbnail ) values(
$picture, $thumbnail )';
 $indata = mysql_query( $insert, $link );


}

function write_form() {
 echo form method='post' action='{$_SERVER['PHP_SELF']}';

 echo pEnter url of large picture: input type='text'
name='picture' /;

 echo pEnter url of thumbnail: input type='text'
name='thumbnail' /;

 echo pinput type='submit' value='Add to Database' /;

 echo /form;
}

 if ( !empty( $_REQUEST['picture'] )  !empty(
$_REQUEST['thumbnail'] ) ) {
   $input = add_to_table( $_REQUEST['picture'],
$_REQUEST['thumbnail'] );
 if(!input) {
   echo 'Error\!';
 }
 else {
  echo 'Data enter successfully\!';
  $idreturn = mysql_insert_id($input);
  echo 'Image inserted to ID ' . $idreturn;
}
  }
 else {
   write_form();
   }

?

/body

/html

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






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



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



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



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



Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Alexander

Alright, I did that. I now get :
INSERT INTO domains ( picture, thumbnail ) values( '', '')

and no data entered.

/* never take a hiatus from programming for a year */

- Original Message - 
From: Niel Archer [EMAIL PROTECTED]

To: php-db@lists.php.net
Sent: Saturday, January 27, 2007 8:29 PM
Subject: Re: [PHP-DB] Am I missing something?



Hi

you need to change this:


$insert = 'INSERT INTO domains ( picture, thumbnail ) values( $picture,
$thumbnail)';


to be:
$insert = INSERT INTO domains ( picture, thumbnail ) values( '$picture',
'$thumbnail');

variables are only interpreted inside double quoted strings.  Within
single quotes, everything is taken exactly as it appears.


Niel

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



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



Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Niel Archer
Hi

 Alright, I did that. I now get :
  INSERT INTO domains ( picture, thumbnail ) values( '', '')
 
 and no data entered.

Then for some reason your variables are empty.  Make sure they have data
on entry to the function.  If they don't keep backtracking until you
find where it's lost.

Niel

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