[PHP-DB] Upload_File

2010-02-10 Thread Bilal Ahmad
Hi I am trying to make a form to provide option to user to upload a file on
a server.Here is the code for my upload.php. It checks all the conditions
etc.. . This code works fine on localhost , and file is uploaded
successfully. But when I use this script online on my server, it gives me
error. couldn't figure out what is error.
What I think is error in move_upload_file, but it isn't returning any error.
File permissions on upload folder are 755.



if((!empty($_FILES['uploaded_file']))  ($_FILES['uploaded_file']['error']
== 0)){

 $ok = 0;
  $filename = basename($_FILES['uploaded_file']['name']);

  $ext = substr($filename, strrpos($filename, '.') + 1);

  if (($ext == jpg || gif || png)  ($_FILES[uploaded_file][type]
== image/jpeg || image/gif || image/png) 
($_FILES[uploaded_file][size]  2097152) ){

  $newname = 'upload/'.$filename;

  if (!file_exists($newname)) {

if
((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
$ok = 1;
  echo It's done! The file has been saved as: .$newname;
} else {
  echo Error: A problem occurred during file upload!;   //This one
executes when ever i try to upload file on server.
}
  } else {
 echo Error: File .$_FILES[uploaded_file][name]. already
exists;
  }
  } else {
echo Error: Only .jpg images under 2MB are accepted for upload;
  }
} else {
 echo Error: No file uploaded;
}

   Thanks
Bilal Farooq Ahmad


Re: [PHP-DB] Image_Problem

2009-07-23 Thread Bilal Ahmad
Hi All, Thanx Richard for your reply, but it isn't working either, please
help me out, Thanks. I can explain the problem again if some one has ne
problem in understanding of the problem. Thanks

On Thu, Jul 23, 2009 at 2:21 PM, Richard Quadling
rquadl...@googlemail.comwrote:

 2009/7/22 Bilal Ahmad engg.bilalma...@googlemail.com:
  Hi All, I wanna ask  a question pleasenV. 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, soon after we get response from ajax).I hope you got the
 problem.
 
 
  Thanks
 

 Try changing ...

  $pi = Imagejpeg($pic,pic.jpg);
  echo $pi;

 to ...

 imagejpeg($pic);



 --
 -
 Richard Quadling
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 Standing on the shoulders of some very clever giants!
 ZOPA : http://uk.zopa.com/member/RQuadling



[PHP-DB] Image_Problem

2009-07-22 Thread Bilal Ahmad
Hi All, I wanna ask  a question pleasenV. 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, soon after we get response from ajax).I hope you got the problem.


Thanks


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