Jump to content

FRSH

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

FRSH's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It does not work for some reason. The two codes that I have tried have both returned a blank page. Its really annoying, can somebody help!?
  2. Because some people may want a url without a www.
  3. <?php function getDomain() { print $_SERVER['HTTP_HOST']; } ?> Call it like this: <?php getDomain(); ?>
  4. 10 views and no reply? am I missing something obvious?
  5. Could you give a bit more information? <?php $domain = "http://whatever.com"; echo $domain; ?>
  6. I'm trying to upload only zip files to the upload directory. Here is the code for verify_upload.php <?php //does pluginfile exist? //if (isset($_POST['pluginfile'])) { // Set all the vadiables $name = $_FILES["file"] ["name"]; $type = $_FILES["file"] ["type"]; $size = $_FILES["file"] ["size"]; $tmp_name = $_FILES["file"] ["tmp_name"]; $error = $_FILES["file"] ["error"]; echo $type; //is the filetype rar/zip? if($type == "application/x-zip-compressed" || "application/zip") { //does the filename already exist? if (file_exists("/upload/".$name)) { //how do I add a _1 to the filename if it already exists? $message ="filename already exists"; }//filename $destination_path = "/upload/"; $target_path = $destination_path . basename($name); if(@move_uploaded_file($tmp_name, $target_path)) { //Upload successful! $message = "file uploaded successfuly!"; } }//if the filetype is not valid else { $message = "only zip and rar filetypes are allowed"; } //}//pluginfile exists //else { //$message .="No file was detected"; //} if(!empty($message)) { echo $message; } ?> Here is the code for the form: <html> <head></head> <body> <form enctype="multipart/form-data" action="verify_upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="file" id="file" type="file" /><br /> <input type="submit" value="Upload File" /> </form> </body> </html>
  7. Check the filepath again
  8. I'm working with the youtube API and the function $relatedVideo->watchURL returns a video url However when I use preg_replace("youtube","test",$relatedVideo->watchURL); it gives me the following error preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Delimiter must not be alphanumeric or backslash in <b>C:\wamp\www\site\test.php</b> on line <b>317 Help please?
  9. Oops never mind guys, I found what I was doing wrong haha Thanks for your help Solved!
  10. How much faster? FRSH: name and email are strings, so you need to put quotes ' around them $sql="INSERT INTO information(name, email) VALUES ('$name', '$email')"; Also, the way you do it, there's a risk of SQL injection. You need to use mysql_real_escape_string to mitigate it, like this: $con = mysql_connect("localhost","fafsd","ffasdfr"); if (!$con) { die('Could not connect: ' . mysql_error()); } $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); Thanks for your reply. Im still getting new records added but with no information in them
  11. Hi, Thanks for your quick reply, but im now getting the following error Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' )' at line 3 what should I do?
  12. I created a table in my database CREATE TABLE `information` ( `ID` int(11) AUTO_INCREAMENT, `name` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, PRIMARY KEY (`ID`) ) Note: I added the auto_increament thing later on this is the code for add.php <?php $name = $_POST['name']; $email = $_POST['email']; $con = mysql_connect("localhost","fafsd","ffasdfr"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DB_2", $con); $sql="INSERT INTO information(name, email) VALUES ('.$name.','.$email.')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "added!"; mysql_close($con) ?> Problem: When I add anything to the database it shows up as two dots Uploaded with ImageShack.us
×
×
  • 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.