+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: PHP - MySQL

  1. #1
    olliepop's Avatar
    olliepop is offline x10 Sophmore olliepop is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    137

    Exclamation PHP - MySQL

    Hi, i am very experienced with PHP and MySQL. I am not a newb or anything, but with this script i seriously do not know what's wrong!

    Here is the entire page code, except for of course the mysql db name, username and password.

    Click here for the CODE of the page

    Please help me with this!

    I haven't included the code here because it would just make the post very long.
    Last edited by olliepop; 10-14-2008 at 11:37 PM. Reason: Addition..

  2. #2
    Myokram is offline x10Hosting Member Myokram is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    30

    Re: PHP - MySQL

    Perhaps it would be easier if you just tell what's the problem with that script. Does it display an error message? What it says?

  3. #3
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: PHP - MySQL

    Might I recommend you make the same file with .php as well so we can see the code and the results?
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

  4. #4
    dickey's Avatar
    dickey is offline x10 Sophmore dickey is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    128

    Re: PHP - MySQL

    Basically if there be errors check syntax first.

    then
    Code:
      if($_POST['step']=="1") {
        $form="2";
      } elseif($_POST['step']=="2") {
        $form="2";
      }
    is confusing or it might be wrong. or it might be part of your logic.

    another point is maybe you should initialize the variable '$form' as some php installations tend to give out errors if using an improperly initialized variable.

    but then again your problem might not be your code if you are having problems connecting mysql.... then maybe it is your php version in x10hosting where (i'm not sure but...) I think they disable mysql in the basic version. try to upgrade to intermediate version.

    if not maybe give more details as to what the problem is?

  5. #5
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: PHP - MySQL

    Code:
      if($_POST['step']=="1") {
        $form="2";
      } elseif($_POST['step']=="2") {
        $form="2";
      }
    I suspect that this should be

    Code:
      if($_POST['step']=="1") {
        $form="1";
      } elseif($_POST['step']=="2") {
        $form="2";
      }

  6. #6
    olliepop's Avatar
    olliepop is offline x10 Sophmore olliepop is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    137

    Re: PHP - MySQL

    There are no errors, everything runs fine. The only problem is that when it comes to adding the information into the database the information isn't actually inserted.

    I can't seem to find out whats wrong.. its so weird!

    Ok, the .php file is http://www.olliepop.x10hosting.com/mmo/add_db.php
    Edit:
    Sorry for dub but the problem, i believe, is here:

    PHP Code:
    if($_POST['table']!=NULL || $_POST['table']!="") {
    mysql_select_db("REMOVED_FOR_SECRUITY_ISSUES"$con);
    mysql_query("INSERT INTO ".$_POST['table']." (".$_POST['c1'].", ".$_POST['c2'].", ".$_POST['c3'].", ".$_POST['c4'].", ".$_POST['c5'].", ".$_POST['c6'].", ".$_POST['c7'].", ".$_POST['c8'].", ".$_POST['c9'].", ".$_POST['c10'].") 
    VALUES ('"
    .$_POST['r1']."', '".$_POST['r2']."', '".$_POST['r3']."', '".$_POST['r4']."', '".$_POST['r5']."', '".$_POST['r6']."', '".$_POST['r7']."', '".$_POST['r8']."', '".$_POST['r9']."', '".$_POST['r10']."')");
    $works="1";
    echo 
    "Inserted values into database successfully!";

    :dunno:
    Last edited by olliepop; 10-16-2008 at 11:35 PM. Reason: Automerged Doublepost

  7. #7
    Salvatos's Avatar
    Salvatos is offline x10 Lieutenant Salvatos is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Québec, Canada
    Posts
    271

    Re: PHP - MySQL

    I doubt it will do anything but might as well have a look.
    Shouldn't
    if($_POST['table']!=NULL || $_POST['table']!="") {
    be
    if($_POST['table']!=NULL && $_POST['table']!="") {

    And this one
    if($n!="" || $n!=NULL) {
    does not seem necessary since after it you ask if it equals 1, 2, 3, etc. Otherwise you may want to consider replacing || with &&.

    I doubt it will, but I hope that helps; I can't see anything else.

  8. #8
    olliepop's Avatar
    olliepop is offline x10 Sophmore olliepop is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    137

    Re: PHP - MySQL

    Thanks! But unfortunately it didn't help..
    I wonder if that, when you enter only a value to insert into a new row, but the table has more than columns than values you entered, it won't create..
    For example:
    There are two columns, id and name.
    Then you enter only one value, 10, to insert into a NEW row.
    Will is still create? even if name is null

  9. #9
    natsuki's Avatar
    natsuki is offline x10 Sophmore natsuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    112

    Re: PHP - MySQL

    i'm not quite sure if php automatically converts a null into sql NULL, if not then that could be a problem..
    try
    PHP Code:
    mysql_query("INSERT INTO ".$_POST['table']." (".$_POST['c1'].", ".$_POST['c2'].", ".$_POST['c3'].", ".$_POST['c4'].", ".$_POST['c5'].", ".$_POST['c6'].", ".$_POST['c7'].", ".$_POST['c8'].", ".$_POST['c9'].", ".$_POST['c10'].") 
    VALUES ('"
    .$_POST['r1']."', '".$_POST['r2']."', '".$_POST['r3']."', '".$_POST['r4']."', '".$_POST['r5']."', '".$_POST['r6']."', '".$_POST['r7']."', '".$_POST['r8']."', '".$_POST['r9']."', '".$_POST['r10']."')");
    if (
    mysql_errno($con))
    {
        die(
    'Query failed: ' mysql_error($con));
    }
    $works="1";
    echo 
    "Inserted values into database successfully!";

    to see what actually went wrong

  10. #10
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: PHP - MySQL

    PHP Code:
     if($_POST['table']!=NULL || $_POST['table']!="") {
    mysql_select_db("REMOVED_FOR_SECRUITY_ISSUES"$con);
    $result mysql_query("INSERT INTO ".$_POST['table']." (".$_POST['c1'].", ".$_POST['c2'].", ".$_POST['c3'].", ".$_POST['c4'].", ".$_POST['c5'].", ".$_POST['c6'].", ".$_POST['c7'].", ".$_POST['c8'].", ".$_POST['c9'].", ".$_POST['c10'].") 
    VALUES ('"
    .$_POST['r1']."', '".$_POST['r2']."', '".$_POST['r3']."', '".$_POST['r4']."', '".$_POST['r5']."', '".$_POST['r6']."', '".$_POST['r7']."', '".$_POST['r8']."', '".$_POST['r9']."', '".$_POST['r10']."')");

    if(!
    $result){
    die(
    "Oh god!");
    }
    $works="1";
    echo 
    "Inserted values into database successfully!";

    This is how I catch SQL errors throughout my own site.
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Places to learn php
    By JaWasabi in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-13-2009, 02:03 AM
  3. [Cossacks] PHP Wont Load MYSQL DOWN
    By pasacom in forum Free Hosting
    Replies: 0
    Last Post: 08-26-2008, 12:30 AM
  4. PHP MySQL Question..
    By anuj_web in forum Programming Help
    Replies: 7
    Last Post: 04-26-2008, 05:43 AM
  5. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers