Jump to content

attaboy

Members
  • Posts

    72
  • Joined

  • Last visited

Everything posted by attaboy

  1. nevermind I was wrong the path wasn't real thanks for the help.
  2. 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.
  3. $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
  4. 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.
  5. 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.
  6. 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.
  7. 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
  8. 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?
  9. 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.
  10. I found it works just fine submitting one at a time.
  11. 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
  12. 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?
  13. I use Dreamweaver myself but I've heard textpad is pretty good
  14. I have this xml file: <?xml version="1.0" encoding="utf-8"?> <links> <category desc="XAML Related"> <link url="http://www.xamlong.com" desc="Xamlong.com" /> <link url="http://www.mobiform.com" desc="Mobiform" /> </category> <category desc="Charlie Related"> <link url="http://jimslounge.com" desc="Jim's Lounge" /> <link url="http://spinach.com" desc="Spinach Blogs" /> </category> </links> I use simple xml to place the links inside inuput tags and display it: <?php function startElemHandler($parser, $name, $attribs) { if (strcasecmp($name, "links") == 0) { echo "<form id='linklist' action='processForm.php' method='POST'>\n"; echo "<table>\n"; } if (strcasecmp($name, "category") == 0) { $desc = $attribs['desc']; echo "<tr>\n"; echo"<td><strong>$desc</strong></td>"; echo"</tr>\n<br>"; } if (strcasecmp($name, "link") == 0) { $url = $attribs['url']; $desc = $attribs['desc']; echo"<tr>"; $echoOut = "<td><input type='text' size='50' name='theLink' value='<a href=\"$url\" />'"; $echoOut .= "</a></td></tr>\n"; echo "$echoOut"; } } function endElemHandler($parser, $name) { if (strcasecmp($name, "links") == 0) { echo "<input name='submit' type='submit' value='Submit'>"; echo "</table>"; echo "</form>"; } } $parser = xml_parser_create(); xml_set_element_handler($parser, 'startElemHandler', 'endElemHandler'); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); $strXML = implode("",file("links3.xml")); xml_parse($parser, $strXML); xml_parser_free($parser); ?> I submit to processForm.php for processing: <?php if (isset($_POST['theLink']))$theurl = $_POST['theLink']; echo $theurl; ?> What I want to do is to put the links contained in my xml file into a form so I can change the values and rewrite the xml file with the new values on submit. At this point I'm able to populate a form with the links from the xml file, to change values in any of the links, and to echo out the last value. I would like to be able to list all the new values when I process the form not just the last value. I think I can figure how rebuild the xml file on my own(maybe). you can test here http://www.jimslounge.com/links3/processForm.php processXML.zip
  15. This is my XML: <?xml version="1.0" encoding="utf-8"?> <links> <category desc="XAML Related"> <link url="http://longhorn.msdn.microsoft.com" desc="Longhorn SDK home" title="Source of Longhorn" /> <link url="http://longhornblogs.com" desc="Longhorn Blogs" /> <link url="http://xamlblogs.com" desc="XAML Blogs" /> <link url="http://www.xamlong.com" desc="Xamlong.com" /> <link url="http://www.mobiform.com" desc="Mobiform" /> <link url="http://www.zaml.com" desc="Zaml.com" /> <link url="http://www.zaml.net" desc="Xaml.net" /> </category> <category desc="XAML Related"> <link url="http://jimslounge.com" desc="Jim's Lounge" title="Source of fun" /> <link url="http://longhorn.com" desc="Longhorn Cheese" /> . . . </xml> This is my php: <?php function startElemHandler($parser, $name, $attribs) { if (strcasecmp($name, "links") == 0) { echo "<div id='linklist'>\n"; } if (strcasecmp($name, "category") == 0) { $desc = $attribs['desc']; echo "<p>$desc</p><ul>\n"; } if (strcasecmp($name, "link") == 0) { $url = $attribs['url']; $desc = $attribs['desc']; [b]$title = $attribs['title'];[/b] echo "<li><a href='$url' target='_blank'"; if ($title != " ") echo " title='$title'"; echo ">"; if ($desc == " ") echo "$url"; else echo "$desc"; echo "</a></li>"; } } function endElemHandler($parser, $name) { if (strcasecmp($name, "links") == 0) { echo "</div>\n"; } if (strcasecmp($name, "category") == 0) { echo "</ul>\n"; } } $parser = xml_parser_create(); xml_set_element_handler($parser, 'startElemHandler', 'endElemHandler'); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); $strXML = implode("",file("links.xml")); xml_parse($parser, $strXML); xml_parser_free($parser); ?> I've created variables to hold values of all the attributes. $url, and $desc don't generate a warning why does $title?
  16. Thanks for your reply. I found something that works. <?php $mysqli = mysqli_connect('localhost', 'root', '', 'jquery'); if(mysqli_connect_errno()) { printf('Connect failed: %s\n', mysqli_connect_error()); exit(); } else { $sql = "SELECT * FROM users"; $res = mysqli_query($mysqli, $sql); if($res) { $number_of_rows = mysqli_num_rows($res); printf("Result set has %d rows.<br>", $number_of_rows); } else { printf("Could nor retreve records: %s\n", mysqli_error($mysqli)); } while($row = mysqli_fetch_array($res)){ echo $row[0].' '; echo $row[1].' '; echo $row[2]; echo '<br>'; } mysqli_free_result($res); mysqli_close($mysqli); } ?> It's only been a few months since my PHP class and already I forgot about the mysqli_fetch_array thing.
  17. This code works fine till I put in this "print($res);" <?php $mysqli = mysqli_connect('localhost', 'root', '', 'jquery'); if(mysqli_connect_errno()) { printf('Connect failed: %s\n', mysqli_connect_error()); exit(); } else { $sql = "SELECT * FROM users"; $res = mysqli_query($mysqli, $sql); if($res) { $number_of_rows = mysqli_num_rows($res); printf("Result set has %d rows.\n", $number_of_rows); } else { printf("Could nor retreve records: %s\n", mysqli_error($mysqli)); } printf($res); // I want to display the results of the SELECT, how is it done? mysqli_free_result($res); mysqli_close($mysqli); } ?> I don't know how to display the output from a SELECT statement.
  18. attaboy

    Easy question!

    As far as I know you can't create a table row that includes a value. This is what I did first I created this table named test then I entered ALTER TABLE test ADD user_id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT; I first tried without specifying PRIMARY KEY but I got an error telling me that auto_increment had to be a KEY Then I inserted my first row of data and explicitly set a value for user_id of 16 INSERT INTO test values('Jim', 61, 'bum', 16); I did a SELECT * FROM test; to see if the value of user_id was 16 and it was then I inserted another row to see if it would auto_increment from there and it did. INSERT INTO test (name, age, job) VALUES ('Tom', 33, 'driver');
  19. MySQL 5.5 using XAMPP on Windows XP I added this to my.ini [mysqld] innodb_data_file_path = innodata1:100M:autoextend shouldn't that create a file called innodata1 somewhere in my data directory?
  20. shouldn't this cause 2 logs to appear in my data folder? MySQL 5.5.16 XAMPP version 1.7.7 Windows XP # The MySQL server [mysqld] key_buffer_size=64M port= 3306 log-bin=mybinlog slow_query_log=1 Yesterday I tried using the command line as well as the my.ini file to get the slow_query log I notice it's in the data folder today so I don't know how I actually got it running. Today I tried to get the binary log running by just using my.ini which is in the bin folder I've stooped and started MySQL several times but still no binary log file shows up in the data folder
  21. she just had a leftover trigger that she needed to drop.
  22. MySQL version 5.5.16 When I run this code I create a trigger on one table that makes updates to 2 other tables whenever I change the code column on the first table. It works fine for me but I gave this code to a friend and when she tries it she gets an error message back saying that her version of MySQL won't support changes to multiple tables from a single trigger. We both installed MySQL around the same time she uses wamp I use xampp. Is it possible this could be fixed by changing an ini setting? delimiter // mysql> CREATE TRIGGER -> CodeChange_au -> AFTER UPDATE -> on country -> FOR EACH ROW -> BEGIN -> set @code_new = NEW.Code; -> set @code_old = OLD.Code; -> UPDATE city SET CountryCode = @code_new -> WHERE CountryCode = @code_old; -> UPDATE CountryLanguage SET CountryCode = @code_new -> WHERE CountryCode = @code_old; -> END//
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.