Jump to content

MasksMaster

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MasksMaster's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you SO much, [b]thorpe[/b]! As soon as I put those couple of lines that check the query I got a reply that... I forgot to connect to a database.  ;D I did and it all worked! Thank you again Very much!
  2. Hello, Everybody! I'm new to PHP/MySQL. For some strange reason I can get the UPDATE part to work. I even tried checking if $other, $ud_id, $ud_received were submitted and they were and show when I use echo. <?php $other=$_COOKIE['other']; $ud_received=$_POST['ud_received']; $ud_id=$_POST['ud_id']; echo $other; echo $ud_received." "."ud_received"; echo $ud_id." "."ud_id"; //this part I replace with needed values $user="username"; $password="password"; $database="database"; //This is where my problem is mysql_connect(localhost,$user,$password); $query="UPDATE $other SET received='$ud_received' WHERE id='$ud_id'"; mysql_query($query); mysql_close(); echo "Record Updated"; ?>
  3. I tried and it is posting for the first part of the script where it assigns it to $table, but still for some reason doesn't insert the variable value into the INSERT. And it is inside the function, so I'm trying the global variable too. Thank you! I restarted Apache and am getting it is not posting. So how would that be solved? But I got it to be posting again! Thank you!
  4. Thank you, [b]Alpine[/b]! I changed it but still seem to encounter the same thing. I'm new to php. Sorry that I'm asking such basic questions! Does this look correct? global $table; $table = $_POST['first']; function insert_db($wish, $link){ require_once('db_login.php'); require_once('DB.php'); $connection = DB::connect("mysql://$db_username:$db_password@$db_host/$db_database"); if (DB::isError($connection)){ die ("Could not connect to the database: <br />". DB::errorMessage($connection)); } $query = "INSERT INTO $table VALUES (NULL,'$wish','$link','','','')"; $result = $connection->query($query); if (DB::isError($result)){ die("Could not query the database: <br />". $query." ".DB::errorMessage($result)); } echo "Inserted OK.<br />"; // Display the table $query = "SELECT * FROM $table"; $result = $connection->query($query); if (DB::isError($result)){ die("Could not query the database: <br />". $query." ".DB::errorMessage($result)); } echo '<table border="1">'; echo "<tr><th>wish</th><th>link</th>><th>Remove</th></tr>"; while ($result_row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { echo "<tr><td>"; echo $result_row["wish"] . '</td><td>'; echo $result_row["link"] . '</td><td>'; echo '<a href="delete.php?id='.$result_row["id"].'">Click to remove if purchased</a></td></tr>'; } echo "</table>"; echo "<a href='view.php'>Add More</a>"; $connection->disconnect(); }
  5. Thank you, [b]ruano84[/b], for looking into it! Unfortunately it does the same thing and I'm just not sure why it wouldn't be giving the value... basically during the register procedure a table being created with all the needed parameters that is called exactly as a first field... Previous version worked just fine, but I needed to change it using PEAR and I'm stuck now... Thank you again!
  6. Hello, I'm putting together a simple wishlist and I encountered a problem where from a login page I'm sending a variable that will be a table name, but as the script executes it gives a mistake showing that it "can't see" where I'm trying to insert the data. Any advice will be very appreciated! Thank you! [i][color=purple]index.html[/color][/i] <form action="view.php" method="post"> First Name: <input type="text" name="first"><br> Last Name: <input type="text" name="last"><br> <input type="Submit"> [i][color=purple]view.php[/color][/i] <?php [b]$table[/b]=$_POST['first']; function insert_db($wish, $link){ require_once('db_login.php'); require_once('DB.php'); $connection = DB::connect("mysql://$db_username:$db_password@$db_host/$db_database"); if (DB::isError($connection)){ die ("Could not connect to the database: <br />". DB::errorMessage($connection)); } $query = "INSERT INTO [b]$table[/b] VALUES (NULL,'$wish','$link','','','')"; $result = $connection->query($query); if (DB::isError($result)){ die("Could not query the database: <br />". $query." ".DB::errorMessage($result)); } echo "Inserted OK.<br />"; $query = "SELECT * FROM [b]$table[/b]"; $result = $connection->query($query); if (DB::isError($result)){ die("Could not query the database: <br />". $query." ".DB::errorMessage($result)); } ... [i]error message[/i] Could not query the database: INSERT INTO VALUES (NULL,'hjk','ghj','','','') syntax 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.