PHP - MySQL

Discuss coding issues, and scripts related to PHP and MySQL.

  1. » mluci12
    Hello
    I have this file upload script and Mysql& PHP insert in database.Why don't work file upload?
    <?php require('includes/config.php');...
    Last post » Admin
    Maybe the : in the array keys is wrong.
    Try this, make sure you have the filename column in the members table; and check for $db /$stmt error....


  2. » mluci12
    Hello!
    When i create PHP apps i create link like domain.com/page?variable=&variable2 , but this is not seo friendly.
    How can i make link like:...
    Last post » Admin
    Hi,
    You can create friendly seo links with mod_rewrite in the .htaccess file.
    For example:
    Options +FollowSymLinks
    RewriteEngine On

    RewriteRule...


  3. » mluci12
    Hello!
    I have a linux server with custom api.I make a php script who check if user pay invoce.How can i make this script acces a link if he return...
    Last post » Admin
    Hi
    If you want to open /redirect to a page address when a condition is True in php, you can use the header() function; like in this example:...


  4. » mluci12
    Hello!I have this php asp(mluci.com/d/cont.php).If users press Bookmark burton he is redirected to a page like(mluci.com/d/bookmark&id=Xx) where...
    Last post » Admin
    Hi
    You can send data to php without page refresh using Ajax. You can learn it from the: , or you can search on intenet for: ajax tutorial .
    - For...


  5. » mluci12
    How can i create a %Like select where variable is a php variable.
    Last post » Admin
    Simple, like this:
    $varnm ='value';
    $sql =  SELECT * FROM table_name WHERE col_1 LIKE '%$varnm' OR col_2 LIKE '%$varnm' ; 


  6. » mluci12
    I have this php code:
    if ($result->num_rows > 0) {
      if($row  =='sell') $html .='<h4 class= telefon2 >'.$row .'</h4>';...
    Last post » Admin
    Hi,
    I suppose the cause is you concatenate the stare result with .= , so, it is added to previous parsing. Try with simple = , or replace your code...


  7. » mluci12
    <form action= method= post >
    Type: <select name= studii id= studii >
    <option value= >---</option>
    <option value=...
    Last post » Admin
    Maybe you need a submit button in the <form>.
    I tested this code in a php file, and it works.
    <?php
    ini_set('display_errors',1);...


  8. » mluci12
    Hello!Have you any idea why this don't work?
    Please!
    <?php
    require('layout2.php');
    $user = trim($_GET );
    header('Content-type: text/html;...
    Last post » Admin
    Hi,
    The second Insert, $sql2, is not sent to mysql (with mysql_query() ).
    Also, the second insert seems wrong. Maybe this is correct:
    $sql2 =...


  9. » StefanS
    Hello, how to solve this error ? I read on different sites about this error, but i don't find solve
    - Error

    Warning: Cannot modify header...
    Last post » Admin
    Hi,
    You can not output something to browser before session_start() or header() function.
    So, the php code with those functions must be before html...


  10. » mluci12
    Hello! I have this html form:
    <div class= col-md-4 col-sm-12 >

    <div class= contact-form bottom >

    <h2>Request an...
    Last post » Admin
    Hi,
    The mysql_query() is deprecated, better use MySQLi or PDO.
    In the php code it is missing the data /value for $telefon. The $telefon variable is...


  11. » mluci12
    Hello!How can i sent am email after mysql insert?
    <?php
    // connect to the  tests  database...
    Last post » Admin
    Hello
    Just add the code with mail() function in the if() that performs and checks the query....


  12. » mluci12
    Hello admin
    I have next php code
      foreach($datas as $row) {
            $html ='';
    if($row  =='wait') $html .='<span class= label label-warning...
    Last post » Admin
    Hi
    There is a second echo mixed in tne echo content.
    Try:
    echo '<tr>
     <td>'.$row .'</td>
     <td>'.$row .'</td>...


  13. » PloMar
    Hello
    I use the following PHP code to get the image data from an external URL.
    $url = $_GET ;...
    Last post » nadera
    problem solved... it works like a charm ... thank you very much dear <3


  14. » frecia18
    <?php
        mysql_connect('localhost', 'root');
        mysql_select_db('inventory');
    if(isset($_GET ) && isset($_GET ) && $_GET...


  15. » Marius
    Hello
    How can I replace part of a string with stars in php?
    For example: marplo to turn into m***lo .
    Last post » Admin
    Hello
    Try the function from this example:
    // Replace in $str the characters starting from $first (0 first character) to $last, with $rep...


  16. » Marius
    Hello
    Is it possible to rewrite /replace a protected method in the extended class, in php?
    Last post » Admin
    Hello
    Yes, you can change the protected attribute of the method in the extended class:
    class A {
      protected function f1(){
        return 'abc';
      }...


  17. » Marius
    Hello,
    I have a form to upload audio files on server. The name of the file, path and size is stored into a table in database.
    The script is...
    Last post » Admin
    Hy,
    You can get the duration of an audio /video file with JavaScript. Then, with JS you can add the duration into an input field in the form for...


  18. » Marius
    Hello
    I have this script that gets the content from an URL address and outputs it to the browser.
    $url = 'the_url_address';...
    Last post » Admin
    Hi,
    You can use the finfo class and the buffer() method to get the mime-type of a string-content.
    Here is an example:
    $url = '...


  19. » Marius
    Hello
    What header() I need to use to output a mp3 file with php so the mp3 to play within the browser?
    Last post » Admin
    Hi
    You can use this header() in php to properly output a mp3 audio file.
    header('Content-Type: audio/mpeg'); 
    - For a complete code see this page:


  20. » Marius
    Hello
    I have a string with these numbers: 3 9 15 23 9 6 8 5 , and I want to get a string with reversed order of those numbers.
    To get this string:...
    Last post » Admin
    Hello
    See the code from this example. Put the numbers into an array, reverse the array items, then put the reversed numbers into a string....


  21. » Marius
    Hello
    I want to make a Select SQL query that sorts ascending by a column, but the rows with NULL values to come last.
    This is the query I use (but...
    Last post » Admin
    Hello
    You could use the ISNULL() function:
    $sql =  SELECT * FROM mp_tab WHERE col < 50 ORDER BY (ISNULL(col) OR col =''), col ASC ; 
    Or, in the...


  22. » PloMar
    Hello,
    Let say I have records into a MySQL table with IDs: 3, 5, 8, 9, 13; and I want to be able to go from one to another by navigation via...
    Last post » MarPlo
    Hi,
    Try this SQL code that combines two sql statements into one.
    SELECT * FROM table_name
    WHERE (
    id = IFNULL((SELECT MIN(id) FROM table_name...


  23. » PloMar
    How can I add a method to a stdClass object?
    For example I try this code:
    $ob = new stdClass;
    $ob->prop = 'val';...
    Last post » Admin
    You cannot dynamically add a method to the stdClass and execute it in the normal way.
    But you can assign that object method to a variable, then...


  24. » PloMar
    I have the following object in php:
    $ob = new stdClass;
    $ob->name = 'some-name';
    $ob->email = 'email-address';
    $ob->site = '
    How can I...
    Last post » Admin
    Hi,
    Just use the: (array) $objectName construction.
    $ob = new stdClass;
    $ob->name = 'some-name';
    $ob->email = 'email-address';...


  25. » PloMar
    Hello,
    I have a script that the user can upload and delete images on server. The issue I am running into is that when the user changes his image on...
    Last post » Admin
    Hi,
    The simpliest way to force a refresh /reload of that image after upload is to add an unique ?hash to the URL /SRC adress (src=...