-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Your need to echo $contents, from the fread (see first post) Oh and I'm an o'reilly fan myself.. so maybe o'reilly PHP cookbook,
-
or this ? <?php $dbQuery = "INSERT INTO ".TBL_USER_AVATARS." VALUES (0, '$fileContent', 'image/png')"; $A= mysql_query($dbQuery, $this->connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $q . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); $avatarNumber = mysql_insert_id(); $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', '$firstname', '$lastname', '$address', '$city', $time, '$birthday', '$avatarNumber')"; $B = mysql_query($q, $this->connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $q . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); return ($A && $B); ?>
-
same way as any other image... <?php $path= "http://www.example.com/logo.jpg"; $size = getimagesize($path); //or even $path = urlencode($path); $size = getimagesize($path); ?> EDIT: also you can use copy to copy the image or imagecreatefromjpeg, providing fopen wrappers have been enabled
-
do be trueful, echo'ing is one of the first thing to learn in php <?php echo "Hello World"; ?> add it to a form is the same as adding it to any html file.. please don't take this the wrong way.. but it maybe an idea to get a book or read up on some tutorials, otherwise your just be copying and pasting instead of programming.. jumping in at the deep end works for some people, (myself included) but with PHP, you miss a lot of the stuff that helps later on.. and find yourself having to go back and read the "basics" anyway (but now you wonder why you didn't read them at the start)
-
quite a few updates again untested, <?php $fileName = $_FILES["file"]["name"]; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // make the random file name do{ $randName = md5(rand() * time()); $pass = "$randName.$ext"; $Check = (file_exists("upimg/$pass") || file_exists("thimg/$pass") || file_exists("avimg/$pass")); }while( $Check ) $uploadedfile = $_FILES['uploadfile']['tmp_name']; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=200; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*200; $newheight3=($height/$width)*100; switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } #1 //$src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass";// . $_FILES["file"]["name"]; if($type == "gif") { imagegif($tmp1,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp1,$filename,100); } imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass";// . $_FILES["file"]["name"]; if($type == "gif") { imagegif($tmp2,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp2,$filename,100); } imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass";// . $_FILES["file"]["name"]; if($type == "gif") { imagegif($tmp3,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp3,$filename,100); } imagedestroy($tmp2); imagedestroy($tmp3); //$name = $_FILES["file"]["name"]; echo "$pass"; // $name"; ?>
-
'interest_rate_year' => 'Total Years' ), //<---Comma 'fr' => array( //this is line 24
-
if they just created it, then when you create it use mysql_insert_id() to get the id, and pass that!
-
my script just displays a blank page, any help please?
MadTechie replied to wmguk's topic in PHP Coding Help
change for ($i=0; $i<$NBFile; $i++) { $Pic_Name1=$FileArray[$i]; to print_r($FileArray); for ($i=0; $i<$NBFile; $i++) { $Pic_Name1=$FileArray[$i]; lets see what we get -
maybe SELECT MAX(id) FROM table unless the last one was deleted! may i ask why ? surely your use mysql_insert_id
-
Sighs... not even a thanx...!
-
No, your need to use the read from text file code and echo that data into the form
-
Heres a cleaned up version UNTESTED, it should save memory, basically it resized to the largest size then resizes the last one to next largest size, etc, this save it resizing one large image each time.. also i have broken it down to clean up as it goes.. i removed the touch as i can see how that would of worked, as your using imagejpeg, i used imagecreatefromjpeg, which mean this will only work with jpegs.. i hope it makes sense <?php $totalChar = 15; $salt = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789"; srand((double)microtime()*1000000); $pass=""; for ($i=0;$i<$totalChar;$i++) $pass = $pass . substr ($salt, rand() % strlen($salt), 1); $uploadedfile = $_FILES['uploadfile']['tmp_name']; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=200; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*200; $newheight3=($height/$width)*100; #1 $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass" . $_FILES["file"]["name"]; imagejpeg($tmp1,$filename,100); imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass" . $_FILES["file"]["name"]; imagejpeg($tmp2,$filename,100); imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass" . $_FILES["file"]["name"]; imagejpeg($tmp3,$filename,100); imagedestroy($tmp2); imagedestroy($tmp3); $name = $_FILES["file"]["name"]; echo "$pass $name"; ?>
-
my script just displays a blank page, any help please?
MadTechie replied to wmguk's topic in PHP Coding Help
No change (as in a blank page) or no images ? lets update some error checking if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //if (substr($file, strlen($file)-3, 3)=="jpg" ) { $FileArray[] = $dir."/".$file; $NBFile=$NBFile+1; //} } } }else{ //update echo "Invalid path";//Add }//add -
personally i would have edit.php as one file, aslo you need to set the new contents (see UPDATE in code) <html> <form action="edit.php" method="post"> <textarea name="data"> </textarea> <input name="submit" type="submit" /> </form> <?php if(isset($_POST['submit'])) { echo "Data posted:<br />"; echo $_POST['data']; $filename = 'faq.txt'; //$somecontent = "Add this to the file\n"; //Get data and set to new contents $somecontent = $_POST['data']; //<---------UPDATED // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } } ?>
-
check that trySeason doesn't have any spaces at the start or end, when you run it from PMA, it will probably add backticks, you could copy the whole thing and add the variables again.. just an idea!
-
Redundant data display based on multi-value fields -- Newbie Help!!!!
MadTechie replied to sw9's topic in PHP Coding Help
maybe this $message = "<html><body><br><br><b>There were ".$rows." new submissions on ".$myDate."."; while ($data = mysql_fetch_assoc($rval)) { // Here is where the issue is. The tables are all connected on the nid field, and both vocabname and termname fields // can have multiple values for the same piece of content. Because of this, everything is getting put out multiple times. $gtitle = strtoupper($data["title"]); $Games[$gtitle] = "</b> <br><br> Submitted By: ".strtoupper($data["name"])."<Br> Program Title: ".$data["title"]."<br>Program Description: ".$data["field_description_0_value"]." <br>".$data["vocabname"].": ".$data["termname"]; } $message .= implode ("<br><br><hr>", $Games ) $to = "me@email.com"; $from = "admin@email.com"; $subject = "New Content"; $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $message .= "</body></html>"; mail($to, $subject, $message, $headers); ?> -
my script just displays a blank page, any help please?
MadTechie replied to wmguk's topic in PHP Coding Help
echo '$loginlower' ; echo '$dir' ; should be echo $loginlower; echo $dir; also is $_GET['login'] being set ? -
thorpe, knows me quite well, infact i consider him my superviser friend on this forum, while i am happy to help you must put some work in yourself, creating a form is a HTML issule and not really a PHP one, attempt to create the form and apply the php code, post back any problems you have, starting points <form method="post"> <textarea name="data"> </textarea> <input name="submit" type="submit" /> </form> <?php if(isset($_POST['submit'])) { echo "Data posted:<br />"; echo $_POST['data']; } ?> you just need to glue it all together
-
using post fields.. something like this (untested) $URL = "http://example.com"; $POSTFIELDS = 'field1=111&field2=222'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec ($ch); curl_close ($ch); print $result; See CURL manual for full details
-
what your trying to do it change the skin of the Gallery.. this is a HTML/CSS question more than PHP
-
basically you need a form to show the data from the text file and to sumit the changes.. heres some examples of reading and writing to a text file fwrite <?php $filename = 'test.txt'; $somecontent = "Add this to the file\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> fread <?php // get contents of a file into a string $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); ?> if you want to go all in, then i would recommend using MySQL, but if its just Static sections then text files are fine.. until you want more
-
try a background task ie $ret = shell_exec('start /B "converting" "'.$ffmpegcmd1.'"');
-
[SOLVED] Only partial success with mySQL file upload/download
MadTechie replied to uladk's topic in PHP Coding Help
try changing header("Content-type: $type"); echo $content; exit; to header("Content-type: $type"); echo stripslashes($content); exit; -
only problem i see if the line ORDER BY triesscored DESC i assume should be ORDER BY tries.scored DESC try that