Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello All, I've added search to my CMS and one column of data in particular is a date column. My whileLoop spits out data I want however it sorts the date field ASC but I need is DESC. I've tried adding the ORDER BY in several different ways however I keep getting an error... what would be the best approach to get it to sort the way I want using my current SELECT statement $search_sql = " SELECT * FROM tracking INNER JOIN sender ON tracking_sender_id = sender_id INNER JOIN method ON tracking_method_id = method_id WHERE (tracking_recepient LIKE '%" . $_POST['search'] . "%')"; the above code works fine but the output sorts ASC, can seem to add the ORDER BY in an appropriate manner to get it DESC. Any advice ? Thank you in advance
  2. Hello you awesome coders. I am getting a strange mesage on this site and need some help if you can to fix. the site is showing this error Notice: Undefined index: Submit in E:\Domains\a\aet.uk.net\user\htdocs\contact.php on line 84 at this page; http://aet.uk.net/contact.php Can you help! the form wont post or work. cheers chris <?php include_once("photoman/common.php");?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php include("includes/header.php"); ?> <script language="JavaScript" type="text/javascript" src="<?php echo $pref ?>scripts/formcheck.js"></script> </head> <body> <?php include("includes/banner.php"); ?> <div id="content" class="<?php echo $sectname ?>"> <?php $pageimage = "includes/$sectname.swf"; if (file_exists($pageimage)) { ?> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','789','height','197','title','<?php echo $sectname." page" ?>','src','includes/<?php echo $sectname ?>','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','includes/<?php echo $sectname ?>' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="789" height="197" title="<?php echo $sectname." page" ?>"> <param name="movie" value="includes/<?php echo $sectname ?>.swf" /> <param name="quality" value="high" /> <embed src="includes/<?php echo $sectname ?>.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed> </object></noscript> <?php } else { $pageimage = "includes/$sectname.jpg"; $pagemax = 250; if (file_exists($pageimage)) { list($sw, $sh, $type, $attr) = getimagesize($pageimage); printf("<div id='pagephoto'><img src=%s alt='%s' %s></div>", $pageimage, $sectname." page image", $attr ); } else { $pageimage = "includes/$sectname.gif"; if (file_exists($pageimage)) { list($sw, $sh, $typwe, $attr) = getimagesize($pageimage); printf("<div id='pagephoto'><img src=%s %s></div>", $pageimage, $attr); } } } ?> <?php $submenu = getMenuXML($sectname); if (count($submenu) > 0 ) { ?> <ul> <?php foreach ($submenu as $subitem) { $imagename = $subitem['image']; if ($imagename == "") { ?> <li><a href="<?php echo $pref ?><?php echo $subitem['href']; ?>"> <?php echo $subitem['name']; ?> </a> </li> <?php } else { ?> <li><a href="<?php echo $pref ?><?php echo $subitem['href']; ?>" onmouseover="MM_swapImage('<?php echo $imagename; ?>','','<?php echo $pref ?>images/<?php echo $subitem['rollover']; ?>',1)" onmouseout="MM_swapImgRestore()"> <img src="<?php echo $pref ?>images/<?php echo ($pagename == $sectname)?$subitem['rollover']:$subitem['image']; ?>" alt="<?php echo $subitem['name']; ?>" id="<?php echo $imagename; ?>" /> </a></li> <?php } } } ?> <div id="pagetext"> <?php $pagefile = "includes/$filename.htm"; if (file_exists($pagefile)) { $text = file_get_contents($pagefile); echo($text); } else { ?> <?php } ?> <?php if($_POST['Submit'] == "Send") { ?> <h2>Thank you for your interest1</h2> <p>We will contact you shortly.</p> <?php // send email $gall = new GalleryXML(); $mailsubj = "Enquiry from ".$gall->gettitle(); $mailto = $gall->getemail(); $mailhead = "From: ".$_POST['email']; $mailbody = "Enquiry from ".$gall->gettitle()."\n"; $mailbody = $mailbody."Name: \t".$_POST['name']."\n"; $mailbody = $mailbody."Phone: \t".$_POST['phone']."\n"; $mailbody = $mailbody."Email: \t".$_POST['email']."\n"; $mailbody = $mailbody."Message: \t".$_POST['message']."\n"; if ($debug) printf("Email message<br>To: %s<br>Subj: %s<br>Email body: %s<br> Header: %s<br>", $mailto, $mailsubj, $mailbody, $mailhead); mail($mailto, $mailsubj, $mailbody, $mailhead); } ?> <table width="50%"> <form action="<?php echo($PHP_SELF)?>" method="post" enctype="multipart/form-data" name="contactform" onSubmit="RGB_validateForm('name','','R','phone','','RisPhone','email','','RisEmail');return document.MM_returnValue"> <tr> <th scope="row">Name</th> <td><input name="name" type="text" id="name" size="32"></td> </tr> <tr> <th scope="row">Telephone</th> <td><input name="phone" type="text" id="phone" size="24"></td> </tr> <tr> <th scope="row">Email</th> <td><input name="email" type="text" id="email" size="32"></td> </tr> <tr> <th scope="row">Message</th> <td><textarea name="message" cols="48" rows="6" id="message"></textarea> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" id="Submit" value="Send"> <input type="reset" name="Reset" id="Reset" value="Reset"> </tr> </form> </table> </div> <?php include("includes/footer.php"); ?> </body> </html>
  3. Hi I am new to php i want to develop a code where i can upload images from backend and also able to delete selected images please provide me help for it
  4. The bbcode below is not parsing code on multiple lines or recognizing line breaks, except the full content code is on one line. <?php function bbcode2html($var) { // code synthax highlighter $var = preg_replace('/\[code](.+?)\[\/code]/i', '<pre><code>$1</code></pre>', $var); return $var; } $content= '[code] <!DOCTYPE html> [/code]'; echo $content= bbcode2html($content); ?> I attempted introducing a new line recognition character into the regex as shown below, but its not working. <?php function bbcode2html($var) { // code synthax highlighter $var = preg_replace('/\[code]\r\n(.+?)\[\/code]/i', '<pre><code>$1</code></pre>', $var); return $var; } $content= '[code] <!DOCTYPE html> [/code]'; echo $content= bbcode2html($content); ?> I would appreciate your suggestions. Thanks.
  5. Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\page\verify_security.php on line 170 earlier the code has been running fine and now it is showing error to me , can you tell something more about it ???
  6. in database, I have faced error where query does not responded properly it was showing the error message that "too much query, user cannot execute more query".... when I increased the limit, it works for sometime and after sometime, it again generates the error , my question here is: "why the error is occurring ?" "what is the correct way to improve the execution of multiple queries at single instance ??? "
  7. Here is my java script $.each(data, function() { var myTable1 = '<tr bgcolor=#ffffff>' + '<td align=center>'+this.vehiclelog_plate+'</td>' + '<td align=center>'+this.vehiclelog_name+'</td>' + '<td align=center>'+this.vehiclelog_date+'</td>' + '<td align=center>'+this.vehiclelog_reftype+'</td>' + '<td align=center>'+this.vehiclelog_refid+'</td>' + '<td align=center>'+this.vehiclelog_description+'</td>' + '</tr>'; $('#tableField').append(myTable1); }); And here is my HTML <div id="tabs-6"> <div id="rform"> <form action = "home.php" method="post"> <fieldset> <legend>View Vehicle Service</legend><br><br> <div> <label class="label-left">Vehicle Name:</label> <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span> <input id="autocomplete" title="type "a"" class="ui-autocomplete-input" name="vehicle_service_search" autocomplete="off"> </div> <div> <button id="searchVehicleDesc" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"> <span class="ui-button-text">View</span> </button> </div> <div> <table border="1" width="650" id = "tableField"> <tr bgcolor=#c0c0c0> <td width=100 align="center"><font face="helvetica"><b>Vehicle Name</b></font></td> <td width=80 align="center"><font face="helvetica"><b>Service Type</b></font></td> <td width=80 align="center"><font face="helvetica"><b>Others</b></font></td> <td width=100 align="center"><font face="helvetica"><b>Reference No.</b></font></td> <td width=80 align="center"><font face="helvetica"><b>Reference Date</b></font></td> <td width=80 align="center"><font face="helvetica"><b>Reference Type</b></font></td> </tr> </table> </div> </fieldset> </form> </div> </div> And here is my response [{"success":1,"plate":"SIX666","name":"YAMAHA ISUZU","date":"0000-00-00","type":"Add Vehicle","id":"0","desc":""},{"success":1,"plate":"VIE597","name":"Resource id #6","date":"2014-05-09","type":"OIL","id":"332142","desc":"castroil"}] Im getting the right response from ajax but I can't put my value to a table I get an alert that says undefined.
  8. so I have been making a php chat service, and when i use this code: Welcome <?php echo $_COOKIE["username"]; ?><br> chatroom: <?php echo $_COOKIE["chatroom"]; ?> <?php $phpfile=$_COOKIE["chatroom"]; $chpage = $phpfile .".php"; $chtext = $phpfile .".txt"; $filename = $_COOKIE["chatroom"] . ".txt"; $myfile = fopen($filename, "r") or die("Unable to open file!"); fopen($myfile); fclose($myfile); include $chtxt; ?> <form action="post.php" method="post"> message: <input type="text" name="msg"><br> <input type="submit"> </form> I get a 403 error. I does anyone know that is wrong with the code? there are more files that set the cookies but they work fine. I can't find anything wrong. please help.
  9. Hi I wondering what i did wrong here: I wont to register 1 or 0 into database. Checkbox file: <?php include("db-tilkobling.php"); $sqlSetning="SELECT * FROM Kvarterbestilt ORDER BY Møtt;"; $sqlResultat=mysqli_query($db,$sqlSetning) or die ("Ikke mulig å hente data fra databasen"); $antallRader=mysqli_num_rows($sqlResultat); print("<input type='checkbox' name='møtt' value='$møtt'>"); ?> Register-møtt.php <?php include("start.html"); ?> <br/> <p>Registrer Møtt/Ikke møtt ved å fylle ut skjemaet under</p> <form method="post" action="" id="registrerAnsattSkjema" name="registrerAnsattSkjema"> <fieldset> <legend>Registrer møtt / ikke møttt</legend> <label for="personnummer">Personnummer</label> <?php include("listeboks-personnummer.php"); ?><br/> <label for="timenummer">Timenummer</label> <?php include("listeboks-timenummer.php"); ?><br/> Sjekk av denne boksen hvis pasient har møtt til time:<br/> <?php include("checkbox-møtt.php"); ?><br/> <input type="submit" name="registrerMottKnapp" id="registrerMottKnapp" value="Registrer møtt/ikke"> <input type="reset" name="nullstill" id="nullstill" value="nullstill"> </fieldset> </form><br/> <?php /* include("valider-mott.php");*/ $registrerMottKnapp=$_POST ["registrerMottKnapp"]; if ($registrerMottKnapp) { $personnummer=$_POST["Personnummer"]; $timenummer=$_POST["Timenummer"]; $møtt=$_POST["Møtt"]; } if ($møtt == '1') { $query = mysql_query("INSERT INTO Kvarterbestilt(Møtt) VALUES('1')"); } /* $lovligFornavn=validerFornavn ($fornavn); $lovligFornavn2=validerFornavn2 ($fornavn); $lovligFornavn3=validerFornavn3 ($fornavn); $lovligEtternavn=validerEtternavn ($etternavn); $lovligEtternavn2=validerEtternavn2 ($etternavn); $lovligEtternavn3=validerEtternavn3 ($etternavn); $lovligYrke=validerYrke ($yrke); $lovligYrke2=validerYrke2 ($yrke); $lovligYrke3=validerYrke3 ($yrke); if (!$lovligFornavn) { print("Fornavn er ikke fylt ut! <br/>"); } else if (!$lovligFornavn2) { print("Bare bokstaver og mellomrom er tillat; $fornavn<br/>"); } else if (!$lovligFornavn3) { print("Ingen tall tillat; $fornavn<br/>"); } else if (!$lovligEtternavn) { print("Etternavn er ikke fylt ut!<br/>"); } else if (!$lovligEtternavn2) { print("Bare bokstaver og mellomrom er tillat; $etternavn<br/>"); } else if (!$lovligEtternavn3) { print("Ingen tall tillat; $etternavn<br/>"); } else if (!$lovligYrke) { print("Yrke er ikke fylt ut!<br/>"); } else if (!$lovligYrke2) { print("Bare bokstaver og mellomrom er tillat; $yrke<br/>"); } else if (!$lovligYrke3) { print("Ingen tall tillat; $yrke<br/>"); } */ /* include("db-tilkobling.php"); $check=mysqli_query($db,"SELECT * FROM Kvarterbestilt WHERE Personnummer='$personnummer' AND Timenummer='$timenummer'"); $checkrows=mysqli_num_rows($check); if($checkrows>0){echo "Ansatt eksiterer fra før";} else { $sqlSetning="INSERT INTO Kvarterbestilt(Møtt) WHERE Personnummer='$personnummer' VALUES ('$møtt');"; mysqli_query ($db,$sqlSetning) or die ("Ikke mulig Ã¥ registrere i db"); print ("Det er registrert at pasienten har $møtt til timen $timenummer"); } } */ include("slutt.html"); ?>
  10. Hello PHP friends, With the help of 2 members here, namely Guru and Clarkey i manage to finalize the Search and this is part of the search.php codes. { $student_id = $row['student_id']; $searchResults .= "<tr>\n"; $searchResults .= " <td>{$row['LRN']}</td>\n"; $searchResults .= " <td>{$row['first_name']}</td>\n"; $searchResults .= " <td>{$row['last_name']}</td>\n"; $searchResults .= " <td>{$row['grade']}</td>\n"; $searchResults .= " <td>{$row['section']}</td>\n"; $searchResults .= " <td><a href='View_Profile.php?id={$student_id}'>View</a> </td>\n"; $searchResults .= " <td><a href='Admin_Edit_Student_Info.php?id={$student_id}'>Update</a></td>\n"; $searchResults .= " <td><a href='Delete.php?id={$student_id}'>Delete</a></td>\n"; $searchResults .= "</tr>\n"; } As we can see we have 3 target links here the VIEW/UPDATE/DELETE. My concern today is to create the Delete.php which if we are going to click the delete. The student selected will be deleted from the database. Thank you very much for reading. Please comment and never hesitate to give suggestions. By the way this is my present codes in connection, please comment and suggest here. //Connect to MySQL Server include 'Connect.php'; mysql_connect($host, $dbusername, $dbpassword); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Escape User Input to help prevent SQL Injection $first_name = mysql_real_escape_string(trim($_GET['first_name'])); // Retrieve data from Query $query = "SELECT * FROM student_information WHERE first_name LIKE '%{$first_name}%'"; $result = mysql_query($query) or die(mysql_error()); :-)
  11. Hi, I am little bit confuse with the result of num_rows that i used in my code. My table invoice have no value in current because i want to check if no value in the table. Here is my code code 1 gives $rowc value as 0 that is correct. $fetch1="select * from invoice"; $val1=$con->query($fetch1); $rowc=$val1->num_rows; echo $rowc; Code 2 gives $rowc value as 1 that is incorrect. $fetch1="select max(id) as id, order_no from invoice"; $val1=$con->query($fetch1); $rowc=$val1->num_rows; echo $rowc; I just want to know why the result giving two different values. Thanks
  12. Hi, This is the output from a var_dump($array); command: array (size=381) 0 => array (size=2) 'Name' => string 'apple' (length=6) 'Number' => float 0.368844763 1 => array (size=2) 'Name' => string 'Blueberry' (length= 'Number' => float 5.59E-6 2 => array (size=2) 'Name' => string 'Cinnamon' (length=5) 'Number' => float -0.0006947 3 => array (size=2) 'Name' => string 'Date' (length=10) 'Number' => float 0.001584453 ... ... ... I want to sort this array from the highest 'Number' float value to the smallest. I tried sorting it with rsort($array,SORT_NUMERIC); but that doesn't give the correct output. What kind of 'sort' should i use to do this?
  13. I know how to implement ajax with php and get output with the help of java-script and ajax... Well, I am just trying to re-direct the page using ajax, but, it is not happening........ What I am doing is that after user logged-in successfully, the email and password are going to check by ajax and if the inputs are correct, the page must re-direct to another page... So, far I am able to verify the correct details, but, the page is not re-directing... You must also see that I want to re-direct the page with ajax only................I am able to redirect the page with java-script but I do not want to include re-direction with java-script in my website !! Thanks for helping me out !!
  14. Im trying to implement the PSR-0 autoloader found here : Autoloader I have simply copied and pasted the code as it is shown in the link so should work out of the box. Here is my file structure for my App: I believe i have set up the file structure correctly. App being the vendor, and then the folders below all being namespaces e.g. Frontend, Base, index will all be namespaces and subnamespaces. The autoloader classes specifies this code in order the initiate the autoloader: $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine'); $classLoader->register(); And in my app i have used this: $classLoader = new SplClassLoader('App', SITE_ROOT); $classLoader->register(); The reason i have only put App as the namespace for the classLoader function is because i need to autoload all classes under the App folder. Here is the initiation of my router class which i believe should be autoloaded so i don't have to include it: $route = new router(); $route->setDefaultController(DEFAULT_CONTROLLER); $route->setDefaultMethod(DEFAULT_METHOD); $route->do_route(); $controller = $route->getController(); $method = $route->getMethod(); $arguments = $route->getArgs(); Is this correct? it doesnt seem to be loading any of the classes, not even the router class which is in the same directory as the autoloader? Im getting pretty confused about what should be parsed to the SPLClassLoader function shown above for a namespace. Any help in this area will be much appreciated Thanks
  15. Hi, I'm quite new to PHP and I have some problem in my php script.How do we allow the user immediately logged into the system after they enter the correct activation code? Here is my script: <?php $username = $_POST['username']; $activation_code = $_POST['activation_code']; $db_host = "localhost"; $db_name = "databasename"; $db_use = "root"; $db_pass = "password"; $link = mysql_connect($db_host, $db_use, $db_pass); mysql_select_db($db_name, $link); $command = "UPDATE email_activation SET check_activation='$activation_code' WHERE username='$username' and activation='$activation_code'"; $result = mysql_query($command); if ($result) { $query = "SELECT * FROM email_activation where username LIKE '%$username%' LIMIT 0 , 1 "; $result = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($result)) { $name = $row['username']; $email = $row['email']; $password = $row['password]; $activation = $row['activation']; $query = "INSERT INTO member (username, email, password, activation) VALUES ('$username','$email','$password','$activation')"; $result = mysql_query($query) OR die(mysql_error()); if ($result) { echo "Congratulations. Your membership has been activated and saved in member table …"; }else{ echo ("Congratulations. Your membership has been activated but it's can't saved in member table …"); } } }else{ echo ("You've entered an invalid username / activation code – please retry"); } ?>
  16. File wont move to directory nor even upload to database here is my code , everything else uploads except the image <?php include('../connect.php'); if(isset($_POST['submit'])){ echo $post_title=mysqli_real_escape_string($connect,$_POST['title']); echo $post_date=date('m-d-y'); echo $post_price=mysqli_real_escape_string($connect,$_POST['price']); echo $post_keywords=mysqli_real_escape_string($connect,$_POST['keywords']); echo $post_content=mysqli_real_escape_string($connect,$_POST['content']); echo $post_image=mysqli_real_escape_string($connect,$_FILES['image']['name']); echo $image_tmp=mysqli_real_escape_string($connect,$_FILES['image']['tmp_name']); if($post_title=='' OR $post_price=='' OR $post_content=='' OR $post_keywords=='' OR $post_image=''){ echo "<script> alert('None of the post fields can be left blank')</script>"; }else{ //moves uploaded image into the image file move_uploaded_file($image_tmp,"../images/$post_image"); $insert_query="INSERT INTO posts (post_title,post_date,post_price,post_image,post_keywords,post_content) VALUES('$post_title','$post_date','$post_price','$post_image','$post_keywords','$post_content')"; if(mysqli_query($connect,$insert_query)){ echo "<script>alert('Succefully posted'); </script>"; } else "<h1> Did not work </h1>"; } if (is_uploaded_file($_FILES['image']['tmp_name'])) { echo "uploaded"; }else echo "could not upload"; var_dump(getcwd()); echo "<a href='logout.php'> Log out </a> <br/>"; echo "<a href='view_posts.php'> View Posts </a>"; ?> <?php } ; ?> here is the html <html> <head> <title> inserting new posts </title> <link rel="stylesheet" type="text/css" href="admin_style.css"> </head> <body> <div id="edit_postform"> <form method="post" action="insert_post.php" enctype="multipart/form-data"> <table width="600" align="centre" border"10"> <tr> <td> <h1> Insert New Post here </h1> </td> </tr> <tr> <td> Post title <td> <td> <input type="text" name="title" size="30"> </td> </tr> <tr> <td> Post Price<td> <td> <input type="text" name="price" size="30"> </td> </tr> <tr> <td> Post keywords<td> <td> <input type="text" name="keywords" size="30"> </td> </tr> <tr> <td> Post image <td> <td> <input type="file" name="image"> </td> </tr> <tr> <td> Post Content <td> <td> <textarea name="content" cols="20" rows="20" size="30"> </textarea> </td> </tr> <tr> <td> <input type="submit" name="submit" value="Publish now"> </td> </tr> </table> </form> </div> </body> </html>
  17. Hello, I am trying to load a txt file into mysql -uroot to create a database with all the tables and everything is prewritten. Here is what I thought I was supposed to write (but it's not working): mysql -uroot < skel_mysql.txt the skel_mysql.txt file is located in xampp/mysql/bin and this is a copy of the text in the file. CREATE DATABASE skel; USE skel; CREATE TABLE customers ( ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, LAST CHAR(20) NOT NULL, FIRST CHAR(20) NOT NULL, PHONE CHAR(20) NOT NULL, SESSID CHAR(32) NOT NULL ); CREATE TABLE products ( SKU INT NOT NULL PRIMARY KEY, NAME CHAR(20) NOT NULL, DESCR VARCHAR(40) NOT NULL, PRICE DECIMAL(9,2) NOT NULL, IMAGE VARCHAR(20) NOT NULL ); INSERT INTO products VALUES(1121,'Small Lab Coat','White Lab Coat Adult Small',15.75,'labcoat.png'), (1122,'Medium Lab Coat','White Lab Coat Adult Medium',15.75,'labcoat.png'), (1123,'Large Lab Coat','White Lab Coat Adult Large',16.75,'labcoat.png'), (1124,'Beaker Kit','Set of 5 different beakers',22.05,'beakers.png'), (1125,'Petri Dishes','Set of three',9.99,'petri.png'), (1126,'Safety Glasses','Women's Safety Glasses',15.75,'wmglass.png'), (1127,'Mens Safety Glasses','Men's Safety Glasses',15.75,'mglass.png'), (1128,'Kids Safety Glasses','Kid's Safety Glasses',15.75, 'kglass.png'), ; CREATE TABLE cart ( ID CHAR(32) NOT NULL, DATE DATETIME NOT NULL, QTY INT NOT NULL, SKU INT NOT NULL ); Side note: I thought there was an error in my database so I dropped it and rewrote the code in a txt file and now I dont want to rewrite everything in the cmd prompt. This is for a simple shopping cart assignment Im doing for a PHP class.
  18. Hi, So I have an array var playlist = new Array(); And in it I have songs as so: playlist[0] = 'Avicii - Levels'; playlist[1] = 'Song'; playlist[2] = 'Song'; playlist[3] = 'Song'; playlist[4] = 'Song'; playlist[5] = 'Song'; playlist[6] = 'Song'; playlist[7] = 'Song'; playlist[8] = 'Song'; playlist[9] = 'Song'; playlist[10] = 'Song'; Now I'm not an expert at MySQL so I was wondering if there would be an easier way to do this with MySQL instead if adding playlist[number] = 'Song"; after every line. It would search the MySQL database for a column named songs and it would automatically put them into the array 'playlist'. Also code examples or a finished product would be VERY helpful! Thanks
  19. Hello again, Pros! I need an advisory jump start so I don't have any code or examples to show. And I am not asking for any code. Just advise on the best possible way to proceed with my project.. PROJECT : I am trying to build a system that will allow me to upload video files to several different categories within several different categories etc. Boy...that sounds confusing already. First let me start by saying the video files are home recordings of reviews for my whole family's use and are not illegal in any way at all. This is what I want to be able to do: I have video files that fit into several different states (3). Within the first state I have 2 cities - within the second state I have 5 cities - and in the third state I have 1 city. Within all the cities are 5 different categories. I want to be able to upload them like so..... State1 | City1 | Category1 | video lands here. State1 | City1 | Category4 | video lands here. I am familiar with the php video upload script but from everything I have read, it will only upload to one directory. I don't know how to go about getting the videos into the correct directory. I thought about using a database driven drop down menu with an upload script for each state, city, category. I am willing to setup all the directories and scripts do this if its the best way but before I spend hours and hours testing all this, I thought I would check with you experts first. Is there a better way than what I am thinking? Thanks again in advance for your time and patience with me. CR
  20. Here is the deal, its a simple script. 1-read a site link from a sql table**(sql1) 2-mark the sql1 line as read 3-goes to the site and capture several pieces of data(i used curl) 4-modify the read data 5-writes the data in another sql(sql2) So i did this with a few links, but i have to do this with 5~10 millions of links, what would be the better way to get performance and speed?
  21. Hi, I have a problem deleting duplicate rows in a .csv file. I have posted on another forum, but with no useful help, the file is still saving the row of .csv even in I write in a duplicate mobile number. The record file is only 2000 lines long and performance is not an issue. Please help, as it is time-sensitive. Cheers <?php $filename = "input.csv"; $csv_output .= "\n";$title=$_GET[title];$fname=$_GET[fname]; $sname=$_GET[sname];$notes=$_GET[notes];$mobile=$_GET[mobile]; $string="$title,$fname,$sname,$mobile,$notes,$csv_output"; $file = fopen($filename, "c"); flock($file, LOCK_EX); $stat = fstat($file) if($stat['size'] == 0) { // file created for the first time fwrite($file, "Title,First Name,Last Name,MobileNumber,Notes\n$string"); flock($file, LOCK_UN); fclose($file); return; } while (($buffer = fgets($file, 2188)) !== false) { if(!stripos($buffer, $mobile) { $somecontent .= $buffer; } else { flock($file, LOCK_UN); fclose($file); return; } } // Otherwise fwrite() the line else { fwrite($file, $string); } flock($file, LOCK_UN);fclose($file); ?>
  22. Hi everyone I have created my query that returns the results I require however I need to change how its displayed Company Spec company 1 spec1 company 1 spec2 company 1 spec3 company 1 spec1 company 1 spec2 company 2 spec4 company 2 spec5 company 2 spec1 company 2 spec5 company 2 spec4 I need this to be displayed like this: Company Spec company 1 spec1 spec2 spec3 company 2 spec1 spec4 spec5 So I need the company name distinct but I want the spec values to show under the company as well rather than on each row shown above. I know it looks like the values a duplicated but they're not - theres other columns in the database with unique values I hope that makes sense... can anyone help me please? I have tried using GROUP by and the company appears once but then how do I display all the corresponding spec options under the company? Hope someone can help me with this. Many thanks
  23. I am new to PHP and MySQL, but not to coding in general. I finally got brave and I am trying to move from a MS Access database to a server based MySQL database with a web enabled front end. The goal of the database is to be online aviation logbook with the ability to enter/retrieve data with my iPhone. My ultimate end state is to code my app for the phone. I have exported all of my Access data to a MySQL database on server. I've spent the last two weeks learning PHP and MySQL by writing small scripts and expanding as I learned. I finally reached a point where I was ready to write the code for entering all of the data for a flight and inserting into the database. I had mastered all of the sub-steps. I built a form for entering the data. The form querys the DB to populate some of the drop down menus. All of that works fine and the drop menus are populated with information from the DB. After I click on the "submit" button, the code throws an error. I eventually learned how to capture and display the error. I was getting the following: Access denied for user ''@'localhost' to database 'FltLogbook'. Initially, I thought that maybe there was some sort of data type mismatch (I wasn't displaying the error initially, just a phrase stating the add failed) and I ended up commenting out the INSERT query and trying to insert just one piece (column) of data. That didn't work. Then I finally stumbled on the method to display the error. After seeing the actual error statement, I thought that I was losing DB connectivity after pressing submit and executing the code or it may be a permission issue. If I place the "INSERT" code up in the portion of the code where the form is built, I can successfully add a record. So my username/password has the correct privileges since I can add a record using the code - just not where I want to do it. After googling, it looks like the code is passing a null value for user (and I assume password). I have no idea why, but suspect it has something to do with the "POST" process after the submit. Stumbling upon another function (connection_status), it passes a "0" for normal in both sections of the code. I am truly stumped and have been this way for three days now!! I have googled anonymous, the exact error phrase, etc. None of it has helped me bridge this impasse. I am sure, as in previous coding impasses, it will be quite obvious to someone. Thanks for any help, Heed <?php $conn = mysqli_connect("localhost", $_POST[user], $_POST[password], "FltLogbook"); if ($_POST[op] != "add") { //Form not shown, show it $display="<h1>Add Logbook Entry</h1>"; $CnxSt = connection_status(); $display .= "Connection Status: $CnxSt<br><br>"; $display .= " <form method=\"post\" action=\"$_SERVER[PHP_SELF]\"> <strong>Details:</strong> <table border=\"1\" width=\"520\"> <tr> <td><input type=\"checkbox\" name=\"Sim\">Simulator</td> <td colspan=\"2\">SimType: <select name=\"SimType\"> <option value=\"\"> NA </option> <option value=\"Miltary Visual\"> Military Visual </option> <option value=\"Military Non-Visual\"> Military Non-Visual </option> <option value=\"ATD\"> ATD </option> <option value=\"FTD\"> FTD </option> <option value=\"FFS\"> FFS </option></select></td> </tr> <tr> <td>Date: <input type=\"date\" name=\"FltDate\"></td> <td>Aircraft: <select name=\"Aircraft\"> <option selected=\"selected\" value=\"26\">C-172M</option>"; $AcftQuery="SELECT Aircraft.AirKey,Aircraft.Aircraft, Aircraft.ME, Aircraft.Complex, Aircraft.HighPerf FROM Aircraft"; $AcftResult=mysqli_query($conn, $AcftQuery) or die ("Aircraft Query Failed"); While ($AcftRow=mysqli_fetch_array($AcftResult)) { $AcftKey=$AcftRow['AirKey']; $AcftAircraft=$AcftRow['Aircraft']; $AcftME=$AcftRow['ME']; $AcftComplex=$AcftRow['Complex']; $AcftHP=$AcftRow['HighPerf']; $display .= "<option value=\"$AcftKey\"> $AcftAircraft </option>"; } $display .= " </select> </td> <td>Aircraft ID: <input type=\"text\" name=\"ID\" size=\"8\"></td> </tr> <tr> <td>From: <select name=\"From\"> <option selected=\"selected\" value=\"PVG\">PVG</option>"; $ArfldQuery="SELECT AirfieldID FROM Airfields ORDER BY AirfieldID"; $ArfldResult=mysqli_query($conn, $ArfldQuery) or die ("Airfield Query Failed"); While ($ArfldRow=mysqli_fetch_array($ArfldResult)) { $Arfld=$ArfldRow['AirfieldID']; $display .= "<option value=\"$Arfld\"> $Arfld </option>"; } $display .= " </select> </td> <td>To: <select name=\"To\"> <option selected=\"selected\" value=\"PVG\">PVG</option>"; $ArfldQuery="SELECT AirfieldID FROM Airfields ORDER BY AirfieldID"; $ArfldResult=mysqli_query($conn, $ArfldQuery) or die ("Airfield Query Failed"); While ($ArfldRow=mysqli_fetch_array($ArfldResult)) { $Arfld=$ArfldRow['AirfieldID']; $display .= "<option value=\"$Arfld\"> $Arfld </option>"; } $display .= " </select> </td> <td>Leg: <select name=\"Leg\"> <option value=\"1\">1</option> <option value=\"2\">2</option> <option value=\"3\">3</option> <option value=\"4\">4</option> <option value=\"5\">5</option> <option value=\"6\">6</option> </select> </td> </tr> </table><br> <strong>Flight Time Info:</strong> <table border=\"1\" width=\"520\"> <tr> <td>TPT: <input type=\"text\" name=\"TPT\" size=\"4\"></td> <td>PIC: <input type=\"text\" name=\"PIC\" size=\"4\"></td> <td>SIC: <input type=\"text\" name=\"SIC\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Solo: <input type=\"text\" name=\"Solo\" value=\"0.0\" size=\"4\"></td> <td colspan=\"2\">Dual Received: <input type=\"text\" name=\"Dual\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Cross Country: <input type=\"text\" name=\"XC\" value=\"0.0\" size=\"4\"></td> <td><input type=\"checkbox\" name=\"FARXCntry\" size=\"4\">FAR X-Cntry</td> <td><input type=\"checkbox\" name=\"ATPXCntry\" size=\"4\">ATP X-Cntry</td> </tr> <tr> <td>Single Engine: <input type=\"text\" name=\"SE\" size=\"4\"></td> <td>Multiengine: <input type=\"text\" name=\"ME\" size=\"4\"></td> <td>Night: <input type=\"text\" name=\"NT\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Complex: <input type=\"text\" name=\"Complex\" value=\"0.0\" size=\"4\"></td> <td colspan=\"2\">High Performance: <input type=\"text\" name=\"HP\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Instrument: <input type=\"text\" name=\"Inst\" value=\"0.0\" size=\"4\"></td> <td colspan=\"2\">Sim Instrument: <input type=\"text\" name=\"SimInst\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Instructor: <input type=\"text\" name=\"Instructor\" value=\"0.0\" size=\"4\"></td> <td>Pre-Post: <input type=\"text\" name=\"PrePost\" value=\"0.0\" size=\"4\"></td> <td>Ground: <input type=\"text\" name=\"Ground\" value=\"0.0\" size=\"4\"></td> </tr> </table><br> <strong>Actual Approaches:</strong> <table border=\"1\" width=\"520\"> <tr> <td>Precision: <input type=\"text\" name=\"PrecAct\" value=\"0\" size=\"3\"></td> <td>Non-Precision: <input type=\"text\" name=\"NonPrecAct\" value=\"0\" size=\"3\"></td> </tr> </table><br> <strong>Simulated Approaches:</strong> <table border=\"1\" width=\"520\"> <tr> <td>Precision: <input type=\"text\" name=\"PrecSim\" value=\"0\" size=\"3\"></td> <td>Non-Precision: <input type=\"text\" name=\"NonPrecSim\" value=\"0\" size=\"3\"></td> </tr> </table><br> <strong>Landings:</strong> <table border=\"1\" width=\"520\"> <tr> <td>Day Landings: <input type=\"text\" name=\"DayLdg\" size=\"3\"></td> <td>Night Landings: <input type=\"text\" name=\"NtLdg\" size=\"3\"></td> </tr> </table><br> <strong>Remarks:</strong><br> <textarea name=\"Remarks\" rows=\"5\" cols=\"70\"></textarea> <input type=\"hidden\" name=\"op\" value=\"add\"> <p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"></p> </FORM>"; } else if ($_POST[op] == "add") { if ($_POST[Sim] == "") { $_POST[Sim] = "0"; } else { $_POST[Sim] = "1"; } if ($_POST[FARXCntry] == "") { $_POST[FARXCntry] = "0"; } else { $_POST[FARXCntry] = "1"; } if ($_POST[ATPXCntry] == "") { $_POST[ATPXCntry] = "0"; } else { $_POST[ATPXCntry] = "1"; } // $add_flt = "INSERT INTO FlightData (Date, MakeModel, AircraftID, Simulator, SimType, AfldFrom, AfldTo, // Leg, TPT, PIC, SIC, Solo, Dual, Night, XCntry, SE, ME, Complex, HighPerf, Inst_Act, Inst_Sim, // Instructor, PrePost, Ground, Prec_Act, Prec_Sim, NonPrec_Act, NonPrec_Sim, DCL, NCL, // FAR_XCntry, ATP_XCntry, Remarks) // VALUES ('$_POST[FltDate]', '$_POST[Aircraft]', '$_POST[ID],$_POST[Sim]', '$_POST[SimType]', '$_POST[From]', // '$_POST[To]', '$_POST[Leg]', '$_POST[TPT]', '$_POST[PIC]', '$_POST[SIC]', '$_POST[Solo]', '$_POST[Dual]', // '$_POST[NT]', '$_POST[XC]', '$_POST[SE]', '$_POST[ME]', '$_POST[Complex]', '$_POST[HP]', '$_POST[Inst]', // '$_POST[SimInst]', '$_POST[Instructor]', '$_POST[PrePost]', '$_POST[Ground]', '$_POST[PrecAct]', // '$_POST[PrecSim]', '$_POST[NonPrecAct]', '$_POST[NonPreSim]', '$_POST[DayLdg]', '$_POST[NtLdg]', // '$_POST[FARXCntry]', '$_POST[ATPXCntry]', '$_POST[Remarks]')"; $add_flt = "INSERT INTO FlightData (Date, MakeModel) VALUES ('$_POST[FltDate]', '$_POST[Aircraft]')"; $result = mysqli_query($conn, $add_flt) or die('Error: '. mysqli_connect_error()); $display = "<h1>Entry Added</h1> <p>Your entry was added.</p><br> <p>$_POST[FltDate] | $Make </p>"; // $CnxSt = connection_status(); // $display .= "Connection Status: $CnxSt<br><br>"; // $display .= "$_POST[FltDate] / $_POST[Aircraft] / $_POST[ID] / $_POST[Sim] / $_POST[FARXCntry] / $_POST[ATPXCntry]"; } ?> <html> <head> <title>Add Logbook Entry></title> </head> <body> <?php echo $display; ?> </body> </html>
  24. I have a script that allows me to post comments, but when i try to delete that comment i get a error message telling me that a specific variable is undefined. I refresh the page and try again, and suddently it works. template_test.php <?php if($author == $log_username || $account_name == $log_username ){ $statusDeleteButton = '<span id="sdb_'.$statusid.'"><a href="#" onclick="return false;" onmousedown="deleteStatus(\''.$statusid.'\',\'status_'.$statusid.'\',\''.$DB_table.'\');" title="DELETE THIS STATUS AND ITS REPLIES">delete status</a></span> '; } ?> <script> function deleteStatus(statusid,statusbox,document){ var ajax = ajaxObj("POST", "php_parsers/status_system2.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) === true) { if(ajax.responseText === "delete_ok"){ // remove the div all of the tekst is inside, the textarea and the reply button _(statusbox).style.display = 'none'; _("replytext_"+statusid).style.display = 'none'; _("replyBtn_"+statusid).style.display = 'none'; } else { alert(ajax.responseText); } } } ajax.send("action=delete_status&statusid="+statusid+"&document="+document); }; </script> php_parsers/status_system2.php <?php // fires of when the someone deletes a thread if (isset($_POST['action']) && $_POST['action'] == "delete_status" && !empty($_POST['document'])){ if(!isset($_POST['statusid']) || $_POST['statusid'] == ""){ echo "status id is missing"; exit(); } // sanitize the inserted status id $statusid = preg_replace('#[^0-9]#', '', $_POST['statusid']); // check to see which page the user is on, then give different variables that contain different DB tables // check to see whether or not the user replied to a status from user.php or watch.php if($_POST['document'] == "comments") // this means the user replied within watch.php { $DB_table = "comments"; } else if($_POST['document'] == "status") // this mean that the user replied within user.php { $DB_table = "status"; }else{ echo 'Error: this is an unexpected situation. What is happening? ' . $_POST['document']; } // Check to make sure the person deleting this reply is either the account owner or the person who wrote it if($DB_table == null){ echo 'Can\'t look up nuthin'; }else{ // Check to make sure the person deleting this reply is either the //account owner or the person who wrote it $sql = "SELECT account_name, author FROM $DB_table WHERE id='$statusid' LIMIT 1"; $query = mysqli_query($con, $sql); while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $account_name = $row["account_name"]; $author = $row["author"]; } } // delete the thread and it replies with the same osid if ($author == $log_username || $account_name == $log_username) { $sql = "DELETE FROM $DB_table WHERE osid='$statusid'"; mysqli_query($con, $sql); echo "delete_ok"; exit(); } } ?>
  25. i am getting this error Notice: Undefined index: image . i am trying to upload an image to databse . I cannot figure out whats going on , everything else uploads except the image, not even the image name is uploaded to database below is code the size of the file is only 3kb. the echo $max_upload = (int)(ini_get('upload_max_filesize')); echo "<pre>" . print_r($_POST, true) . "</pre>"; echo "<pre>". var_dump($_FILES['image']) . "</pre>"; the print_r displays as Array ( [title] => This is a post [author] => Me [keywords] => posting [image] => url.jpg [content] => this is a new post [submit] => Publish now ) displays as NULL the vardump below is actual code. <html> <head> <title> inserting new posts </title> </head> <body> <form method="post" action="insert_post.php" enctype="multipart/form-data/"> <table width="600" align="centre" border"10"> <tr> <td> <h1> Insert New Post here </h1> </td> </tr> <tr> <td> Post title <td> <td> <input type="text" name="title" size="30"> </td> </tr> <tr> <td> Post Author<td> <td> <input type="text" name="author" size="30"> </td> </tr> <tr> <td> Post keywords<td> <td> <input type="text" name="keywords" size="30"> </td> </tr> <tr> <td> Post image <td> <td> <input type="file" name="image"> </td> </tr> <tr> <td> Post Content <td> <td> <textarea name="content" cols="20" rows="20" size="30"> </textarea> </td> </tr> <tr> <td> Post title <td> <td> <input type="text" name="title" size="30"> </td> </tr> <tr> <td> <input type="submit" name="submit" value="Publish now"> </td> </tr> </table> </form> </body> </html> <?php include('../includes/connect.php'); if(isset($_POST['submit'])){ echo $post_title=$_POST['title']; echo $post_date=date('d-m-y'); echo $post_author=$_POST['author']; echo $post_keywords=$_POST['keywords']; echo $post_content=$_POST['content']; echo $post_image=$_FILES['image']['name']; echo $image_tmp=$_FILES['image']['tmp_name']; if($post_title=='' or $post_keywords=='' or $post_content=='' or $post_author==''){ echo "<script> alert('none of the fields can be empty')</script>"; exit(); } else{ move_uploaded_file($image_tmp,"../images/$post_image"); //query is below to insert data $insert_query="INSERT into posts (post_title,post_date,post_author,post_image,post_keywords,post_content) VALUES('$post_title','$post_date','$post_author','$post_image','$post_keywords','$post_content')"; if(mysqli_query($connect,$insert_query)){ echo " <h1> successfully Posted </h1> "; } else " h1> Did not work </h1>"; } } echo $max_upload = (int)(ini_get('upload_max_filesize')); echo "<pre>" . print_r($_POST, true) . "</pre>"; echo "<pre>". var_dump($_FILES['image']) . "</pre>"; ?> thanks in advance guys.
×
×
  • 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.