Re: [PHP-DB] Prepared Statement Insert Problem

2009-07-21 Thread kesavan trichy rengarajan
Remove the quotes around the variables in all your statements.
For example, this statement:
mysqli_stmt_bind_param($submitadmin, isss, '$numrows', '$admin',
sha1('$password'), '$email');

could be rewritten as:
mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin,
sha1($password), $email);

On Tue, Jul 21, 2009 at 8:01 PM, Jason Carson ja...@jasoncarson.ca wrote:

 Hello everyone, I have a problem.

 I use the following to *try* and insert data into my MySQL database...

 //Variables come from a form
 $username= $_POST['username'];
 $password = $_POST['password'];
 $email = $_POST['email'];


 //Connect to the database
 $connect = mysqli_connect($hostname, $dbusername, $dbpassword,
 $database)or die(cannot connect);


 //Find out how many rows in the database
 $aidcount = mysqli_query ($connect, SELECT * FROM administrator);
 $numrows = mysqli_num_rows($aidcount);


 //The next 3 lines are using prepared statements to insert data but the
 //second line ...mysqli_stmt_bind_param.. results in this error...
 //Fatal error: Only variables can be passed by reference in file.php line
 46

 $submitadmin = mysqli_prepare($connect2, INSERT INTO administrator VALUES
 (?, ?, ?, ?));

 mysqli_stmt_bind_param($submitadmin, isss, '$numrows', '$admin',
 sha1('$password'), '$email');

 mysqli_stmt_execute($submitadmin);

 ...anyone know how I can solve this problem so I can insert data into my
 database with prepared statements?


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




Re: [PHP-DB] Prepared Statement Insert Problem

2009-07-21 Thread Jason Carson
That worked, thanks!

 Remove the quotes around the variables in all your statements.
 For example, this statement:
 mysqli_stmt_bind_param($submitadmin, isss, '$numrows', '$admin',
 sha1('$password'), '$email');

 could be rewritten as:
 mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin,
 sha1($password), $email);

 On Tue, Jul 21, 2009 at 8:01 PM, Jason Carson ja...@jasoncarson.ca
 wrote:

 Hello everyone, I have a problem.

 I use the following to *try* and insert data into my MySQL database...

 //Variables come from a form
 $username= $_POST['username'];
 $password = $_POST['password'];
 $email = $_POST['email'];


 //Connect to the database
 $connect = mysqli_connect($hostname, $dbusername, $dbpassword,
 $database)or die(cannot connect);


 //Find out how many rows in the database
 $aidcount = mysqli_query ($connect, SELECT * FROM administrator);
 $numrows = mysqli_num_rows($aidcount);


 //The next 3 lines are using prepared statements to insert data but the
 //second line ...mysqli_stmt_bind_param.. results in this error...
 //Fatal error: Only variables can be passed by reference in file.php
 line
 46

 $submitadmin = mysqli_prepare($connect2, INSERT INTO administrator
 VALUES
 (?, ?, ?, ?));

 mysqli_stmt_bind_param($submitadmin, isss, '$numrows', '$admin',
 sha1('$password'), '$email');

 mysqli_stmt_execute($submitadmin);

 ...anyone know how I can solve this problem so I can insert data into my
 database with prepared statements?


 --
 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] Prepared Statement Insert Problem

2009-07-21 Thread Christopher Jones



kesavan trichy rengarajan wrote:

 could be rewritten as:
 mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin,
 sha1($password), $email);

Turning on E_STRICT in PHP 5.3 will show

  PHP Strict Standards:  Only variables should be passed by reference

This is also true in earlier versions although the warning isn't
displayed.

For compliance, try:

  $s = sha1($password);
  mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin, $s, $email);

Chris

--
Blog: http://blogs.oracle.com/opal
Twitter:  http://twitter.com/ghrd

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



Re: [PHP-DB] Prepared Statement Insert Problem

2009-07-21 Thread Jason Carson
Done. Thanks for letting me know about that.


 kesavan trichy rengarajan wrote:

   could be rewritten as:
   mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin,
   sha1($password), $email);

 Turning on E_STRICT in PHP 5.3 will show

PHP Strict Standards:  Only variables should be passed by reference

 This is also true in earlier versions although the warning isn't
 displayed.

 For compliance, try:

$s = sha1($password);
mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin, $s,
 $email);

 Chris

 --
 Blog: http://blogs.oracle.com/opal
 Twitter:  http://twitter.com/ghrd

 --
 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] Prepared Statement Insert Problem

2009-07-21 Thread Bilal Ahmad
Hi i wanna ask  a question. I am trying to create an image on fly, please do
help me , following is the code.

*File Name : Font.php
Code: *

html
head
titleImage Creation/title

script language=javascript
var xmlhttp;

function showPic()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert (Browser does not support HTTP Request);
  return;
  }

var text = document.getElementById(textfield).value;

var url=image.php;
url=url+?text=text;
alert(url);
url=url+sid=+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open(GET,url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
if(xmlhttp.responseText == 1)
{
document.getElementById(pic).style.display=block;
}
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject(Microsoft.XMLHTTP);
  }
return null;
}
/script
/head
body
form name=form1 method=post action= onSubmit= return false;
  table width=304 border=1
tr
  td colspan=2div align=centerText/div/td
/tr
tr
  tdText/td
  tdlabel
input type=text name=textfield id=textfield
  /label/td
/tr
tr
  td colspan=2label
div align=center
  input type=submit name=button id=button value=Update
onClick=showPic()
  /div
  /label/td
/tr
tr
  td colspan=2div id=pic style=display:noneimg src=pic.jpg
//div/td
/tr
  /table
/form
/body
/html

*File Name : image.php
Code:*

[php]

$name = $_GET['text'];

 $pic = imagecreatetruecolor(100, 100);
 $text_color = imagecolorallocate($pic, 255, 255, 255);
 imagestring($pic, 10, 15, 15,  $name, $text_color);
 $pi = Imagejpeg($pic,pic.jpg);
 echo $pi;
 ImageDestroy($pic);

[/php]

*Problem: *

What this code is doing is that, it creates a new image with the text (that
user enters) on it, but loads the image that was created previously, I want
that it should display the text on the picture which users enter on the fly.
( e.g. If user enter TEXT as text it should display TEXT on the picture
displayed).Hope you got the problem.

Thanks

For me, it shoould work like this: User enters text intext filed (in
font.html) , when pressed button, image.php should create an im
On Tue, Jul 21, 2009 at 10:46 PM, Christopher Jones 
christopher.jo...@oracle.com wrote:



 kesavan trichy rengarajan wrote:

  could be rewritten as:
  mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin,
  sha1($password), $email);

 Turning on E_STRICT in PHP 5.3 will show

  PHP Strict Standards:  Only variables should be passed by reference

 This is also true in earlier versions although the warning isn't
 displayed.

 For compliance, try:

  $s = sha1($password);
  mysqli_stmt_bind_param($submitadmin, isss, $numrows, $admin, $s,
 $email);

 Chris

 --
 Blog: http://blogs.oracle.com/opal
 Twitter:  http://twitter.com/ghrd

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