Jump to content

siric

Members
  • Posts

    116
  • Joined

  • Last visited

Posts posted by siric

  1. You have the explode the wrong way around

     

    should be

     

    $file_name_array = explode(".", $newfile);
    

     

    and

    $final_name = $file_name_array[0].".".$file_name_array[1];  //was missing $ and correct concatenation
    

     

    Don't forget your semicolons at the ends of the lines

  2. A string would be easier for this method.  You need to find the position of <head and </head>.  You then replace all text between first and last string positions.

     

     

    <?
    
    $text = "<head>This is a sentence one.  This is sentence two.</head>";
    
    $headstart = stripos($text, "<head>");
    $headend = stripos($text, "</head>");
    
    $textstart = $headstart + 6;  //length of <head> is added
    $textend = $headend;
    
    $textlength = $textend - $textstart;
    $replacement = "This is the replacement text";
    $newtext =  substr_replace($text,$replacement,$textstart,$textlength);
    
    print "newtext - $newtext";
    
    ?>
    
    

     

     

     

    Hope this helps.

  3. Access to the mysql database and access to your application are two totally different things.

     

    Your application should login to the database with the mysql credentials.  In that database you should have a users table which authenticates users and determines if they have the authority to add and delete rows.

     

    So your user table would be something like this

     

    user_id (auto increment)

    username

    password (use md5 when encryption)

    privileges (0 for view only, 1 for add, 2 for add and delete, or whatever you choose)

     

     

    Once a user has logged in, the while they have access to the table that holds the data, they do not have access to the entire mysql database.

     

    Hope this helps.

     

  4. The troubleshooting method that I use to check on queries is to print them.  i.e where you have

    $query = mysql_query("UPDATE carts Set admin_status = 5  WHERE 'cart_id' = .'$per'. 'cart_id'");
    

     

    I do

     

    $query = "UPDATE carts Set admin_status = 5 WHERE 'cart_id' = .'$per'. 'cart_id'";
    print $query;
    

     

    This allows me to

    (1) ensure that the query is what I think it should be and

    (2) run the query manually against my database and to check the results.

     

     

     

     

     

     

  5. Hi,

     

    I am working on a project and have come to a point where I need to run a script that runs a database query and then displays information and I will be calling this from different scripts. Question is would this entail an include or a function?

     

    I know that with a function, I have the added capability of passing variables back and forth, but are there any other benefits/detriments to doing it one way over the other?

     

    Or do I have it completely wrong??

     

    Thanks

     

     

  6. Hi,

     

    I want to create a form that has a conditional question, but cannot find anything anywhere to help.

     

    Basically,

     

    Do you () drive to work () use public transportation

     

    If the answer is "use public transportation", I want to display another radio button question

     

    Do you primarily use the

    () train () bus () other

     

    I understand that it can be done using Javascript and CSS,.

    Can anyone assist?

     

    Thanks

     

    SiRiC

  7. Ok, what I did was this

     

    echo "<meta http-equiv='refresh' content='5; url=".$newpage." ' />\n";

     

    as was suggested.

     

    Because the redirect page has parameters that change,

     

    could be

     

    newpage.php?code=1234&poll=1 or newpage.php?code=32&poll=72 

    etc

     

    I built the variable before the meta tags (did not know that you could do this), and it works.

     

    Thanks to all. :)

  8. Hi,

     

    I have been combing forums but cannot seem to get a answer that fits my problem.

     

    I have a link that calls another page, writes to a table and redirects back to the first page.

     

    I would like to output on the screen that the transaction has been completed, pause for a couple of seconds and then redirect to the first page.

     

    I have used sleep() but all that does is to pause the calling of the second page and then call it and redirect immediately.

     

    I have tried using flush before the sleep and before the echo but nothing works.

     

    If I use

     

    header("Refresh: 5; URL=firstpage.php");

     

    all that does is to keep on calling the page repeatedly.

     

    Any assistance would be appreciated.

     

    Thanks

     

     

  9. Hi,

     

    I am pulling a variable call business name from a table and displaying it in a text box which can be edited.

     

    My code to display it is

     

    <p>Business Name  <input type="text" name="business" size="30" value=<?print $business;?>>
    

     

    However, if the business name contains more than one word, only the first word is displayed.

     

    If I convert the whole line to php, like

    
    <?
    print "<p>Business Name  <input type='text' name='business' size='20' value='$business'>";
    ?>
    

     

    the whole name is displayed.

     

    What am I doing wrong?

     

     

     

     

  10. Hi,

     

    I am inserting temporary values into a table for use on a resultset.  Once I am done I want to clear the data out of the table and have used both

     

    //clear tempbiz table
    $sqlClearBiz = "DELETE from tempbiz";
    $resClearBiz = mysql_query($sqlClearBiz);

     

    and

     

    //clear tempbiz table
    $sqlClearBiz = "TRUNCATE tempbiz";
    $resClearBiz = mysql_query($sqlClearBiz);

     

    but neither work.  However, I run the command in an SQl client, it works.

     

    What can I check??

  11. I would start by breaking down the problem line since I find that double quotes can cause unnecessary stress.

     

    Change

    $query = mysql_query("SELECT Admin FROM Users WHERE Username = '$_SESSION['s_logged_n']' LIMIT 1") or die(mysql_error());

     

    to

     

    $s_logged_n = $_SESSION['s_logged_n']';
    
    $query = mysql_query("SELECT Admin FROM Users WHERE Username = '$s_logged_n' LIMIT 1") or die(mysql_error());

     

     

×
×
  • 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.