-
Posts
72 -
Joined
-
Last visited
About attaboy
- Birthday 08/26/1950
Contact Methods
-
Website URL
http://jimslounge.com
Profile Information
-
Gender
Male
-
Location
Boulder Creek, CA
-
Interests
Coding, hiking, woodworking
attaboy's Achievements

Member (2/5)
1
Reputation
-
nevermind I was wrong the path wasn't real thanks for the help.
-
that would be fine if the path did not exits but as you can see from my output the path does exist. echo $plPath; // returns ../backend/playlist_form.php I thought that maybe by the time I ran echo $absolute_plPath; that $absolute_plPath did not exist so I tried echo realpath('../backend/playlist_form.php'); and still nothing.
-
$plPath = '../backend/playlist_form.php'; $absolute_plPath = realpath($plPath); echo $plPath; // returns ../backend/playlist_form.php echo $absolute_plPath; // returns nothing at all on either my localhost or on my hosted site. going crazy here
-
this code doesn't work on localhost but does on remote host
attaboy replied to attaboy's topic in PHP Coding Help
if i try to upload mp3 the size is 0 the type is blank the extension is mp3, if I upload a wma file I get the size and type and the upload works. -
I have code to upload mp3 to a server when run from my godaddy account it works fine when I run locally I get "invalid file" which is a message generated from the script. I looked through my php.ini file amd dindn't find anything, maybe I just don't know what to look for. I'm sure there must be a setting somewhere in some configuration file that would fix my problem. here is the code <!doctype html> <html> <head> <title> upload songs </title> </head> <body> <form action="upload_songs.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" id="submit" value="Submit"> </form> <?php if (isset($_POST["submit"])) { $path = './upload/'; $maxFileSize = 1 * (1024 * 1024 * 20); // 20Mb $allowedExts = array("mp3", "wma", "aif"); $allowedMimes = array("audio/mp3", "audio/mpeg", "audio/x-ms-wma", "audio/x-aiff"); // $extension = end(explode(".", $_FILES["file"]["name"])); this generates warning pathinfo doesn't $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); if (($_FILES["file"]["size"] < $maxFileSize) && in_array($_FILES["file"]["type"], $allowedMimes) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>"; if (file_exists($path . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], $path . $_FILES["file"]["name"]); echo "Stored in: $path" . $_FILES["file"]["name"]; } } } else { echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Invalid file<br/>"; echo '<pre>' . print_r($_FILES) . '</pre>'; } } ?> </body> </html> Thanks in advance for any ideas.
-
thanks
-
Sorry, I didn't mention a couple of things, first I get the "Invalid file" message also in the first example(the one that works) we have this nomenclature ($_FILES["file"]["type"] == "image/jpeg") I assumed changing to ($_FILES["file"]["type"] == "audio/wav") would allow me allow me to handle audio files maybe $_FILES doesn't have a audio property. One more thing, as I understand the $_FILES ​method is deprecated. I haven't seen any alternative if someone could point me to a good example of an alternative that could be helpful ... thanks.
-
I'm trying to modify this file which uploads images: <form action="upload.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" value="Submit"> </form> <?php if (isset($_POST["submit"])) { $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["file"]["name"])); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>"; if (file_exists("./../upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "./../upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "./../upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } } ?> to one that uploads audio: this is what I have now: <?php if (isset($_POST["submit"])) { $allowedExts = array("mp3", "wav", "wma", "aif"); $extension = end(explode(".", $_FILES["file"]["name"])); if ((($_FILES["file"]["type"] == "audio/mp3") || ($_FILES["file"]["type"] == "audio/wav") || ($_FILES["file"]["type"] == "audio/wma") || ($_FILES["file"]["type"] == "audio/aif")) && ($_FILES["file"]["size"] < 20000000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>"; if (file_exists("./../load/songs" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "./../load/songs" . $_FILES["file"]["name"]); echo "Stored in: " . "./../load/songs" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } } ?> any help will be greatly appreciated .... thanks
-
I get an error every time I use an apostrophe I can fix the problem by putting a backslash in front of the apostrophe but I don't think the guy I'm coding this for will want to do the same thing. How can I best modify my code to accept apostrophes?
-
I have a problem logging in so they sent me a temp password when I go to the email and password page to change my password it tells me to fill the whole form OK I think they must want me to fill in the email part too even though it displays my current email correctly so I enter my email as if it's a new email and it tells me my email is already in use. Looks like a catch 22 if I ever saw one. I hope I don't have to use a temp password every time I come here.
-
I need to make multiple updates to a table at once
attaboy replied to attaboy's topic in PHP Coding Help
I found it works just fine submitting one at a time. -
I have this mysql table called playlist(see attachment) I have a php file called playlist_form.php which i use to generate a form with the contents of the playlist database it looks like this: <?php $con = new mysqli("localhost", "root", "root", "dpsite"); $sql = "SELECT * FROM playlist"; $res = mysqli_query($con,$sql); if($res != FALSE) { $toWrite = ""; while($row = mysqli_fetch_assoc($res)){ $toWrite .= "<form action='process_playlist.php' method='post'>\n"; $toWrite .= "<table>\n"; foreach($row as $key => $value){ $value = "\"".$value."\""; if ($key == "song_title") $toWrite .= "<tr><td>Song Title: </td><td><input type='text' maxlength='30' name=".$key." value=".$value." /></td></tr><br>\n"; if ($key == "artist_name") $toWrite .= "<tr><td>Artist Name: </td><td><input type='text' maxlength='30' name=".$key." value=".$value." /></td></tr><br>\n"; if ($key == "image_path") $toWrite .= "<tr><td>Image: </td><td><input type='text' maxlength='30' name=".$key." value=".$value." /></td></tr><br>\n"; if ($key == "mp3_path") $toWrite .= "<tr><td>mp3: </td><td><input type='text' maxlength='30' name=".$key." value=".$value." /></td></tr><br>\n"; } $toWrite .= "</table>"; } $toWrite .="<p><input type='submit' name='submit' value='Submit' /></p>"; $toWrite .= "</form>"; echo $toWrite; }else{ echo "form was not written!"; } mysqli_close($con); exit; ?> The attachment generated_form shows you the output playlist_form.php generates. To this point everything seems to work well. I can enter new values into any of the songs I want. When I submit this form I want truncate the table then enter the new data but I'm having trouble wrapping my head around this problem. This is what I've done so far: <?php $con = new mysqli("localhost", "root", "root", "dpsite"); if (isset($_POST["song_title"])) $title = $_POST["song_title"]; if (isset($_POST["artist_name"])) $artist = $_POST["artist_name"]; if (isset($_POST["image_path"])) $img = $_POST["image_path"]; if (isset($_POST["mp3_path"])) $mp3 = $_POST["mp3_path"]; //$url = $_POST["url_target"]; $sql = "INSERT INTO playlist(`song_title`,`artist_name`,`image_path`,`mp3_path`) VALUES('$title','$artist','$img','$mp3')"; $res = mysqli_query($con,$sql); while($row = mysqli_fetch_assoc($res)){ foreach($row as $key => $value){ if($title != "") { if($res === TRUE) { echo "data inserted"; }else{ echo "data was not inserted"; } } } } mysqli_close($con); exit; ?> It's very incomplete but If someone can provide a simple example of how to update a table this way I'd be very grateful. thanks
-
Fatal error: Class 'SimpleXMLElemant' not found
attaboy replied to attaboy's topic in PHP Coding Help
OOPS! I misspelled Element. -
I'm trying to learn how to modify xml using simple xml. This is my code: <?php // modifying content $xml = "<root><node1>content</node1></root>"; $sxe = new SimpleXMLElemant($xml); $dom = dom_import_simplexml($sxe); $dom->appendChild(new DOMElement("node2", "content2")); print $sxe->asXML(); ?> This is the error message: Fatal error: Class 'SimpleXMLElemant' not found in C:\xampp\htdocs\Erik_form\modify.php on line 4 Looking at phpinfo() doesn't show me anything useful. I wonder is SimpleXMLElemant() depricated or something?
-
I use Dreamweaver myself but I've heard textpad is pretty good