Jump to content

Update access level


fife

Recommended Posts

Hello.  Basically I have created a form that you fill in and an email gets sent to your in box and you have an access_level of 1.  Within this email there is one field.  A validation_id.  Now what im trying to do is when you click this link it opens the webpage and updates your access_level to 2.  I have wrote my query and array and i can see exactly which bit is wrong.

 

Its where i have

 

validation_id= $validation_id")

 

Now its not working and I can see the error.  Problem is im too new at this to understand why its wrong and how to fix it can anyone help?  Here is the rest of the code.  Also could you please explain?  I would really like to understand it before i move any further.

p.s.  I have already selected my database in the included file

 

      <? include('database_name');
session_start();


  $validation_id =$_GET['validation_id'];
  $FullRec__query=sprintf("SELECT * FROM Members WHERE validation_id= $validation_id"); 

  $FullRec = mysql_query($FullRec__query, $database name) or die(mysql_error());

  $FullRecArray = mysql_fetch_array($FullRec);

  $UdateAccessQuery = sprintf("UPDATE Members SET access_level = '2' WHERE validation_id = $validation_id");

  mysql_query($UdateAccessQuery, $database_name) or die(mysql_error());
?>

Link to comment
Share on other sites

Warning: sprintf() [function.sprintf]: Too few arguments in /home/site/validation_members.php on line 6

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/validation_members.php on line 8

 

Link to comment
Share on other sites

Ok made the change which i think I understand.  Not too sure what %s does but yes it makes sense how ever.  this now popped up which I definately dont understand!

 

Parse error: syntax error, unexpected T_VARIABLE in /home/validation_members.php on line 12

Link to comment
Share on other sites

Cool ok I will have a read of that thank you very much.  I fixed the code on line 12 i was missing a    ,    but now I get a new error.  I will post the error and all of the php on the page again. 

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/validation_members.php on line 8

 

 

<? include('../database name here);

session_start();

 

 

  $validation_id =$_GET['validation_id'];

  $FullRec__query=sprintf("SELECT * FROM Members WHERE validation_id= %s", $validation_id);

 

  $FullRec = mysql_query($FullRec__query, $database name here) or die(mysql_error());

 

  $FullRecArray = mysql_fetch_array($FullRec);

 

  $UdateAccessQuery = sprintf("UPDATE Members SET access_level = '2' WHERE validation_id =%s", $validation_id);

 

  mysql_query($UdateAccessQuery, $database name here) or die(mysql_error());

?>

 

[code=php:0]

Link to comment
Share on other sites

I'm assuming that you are replacing what is actually written for "$database name here." That is where the error is occurring. Make sure that the variable you use there is the same as the one that is set to your mysql_connect() function. If you are only connecting to one database, you can just remove it completely because it will default to the last connection made.

Link to comment
Share on other sites

yes I am definately connecting to the right database name.  Here is my error again

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/sites/yourarena.co.uk/public_html/joining/validation_members.php

and the code with the included page at the top

 


<? include('database name here');
session_start();
//this section is included in the include above
$hostname = "";
$database = "";
$username = "";
$password = "";
$YA1 = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($databasecname here); 

//this is on the validation page its self

  $validation_id =$_GET['validation_id'];
  $FullRec__query=sprintf("SELECT * FROM Members WHERE validation_id= %s", $validation_id);
  $FullRec = mysql_query($FullRec__query, $database name here) or die(mysql_error());
  $FullRecArray = mysql_fetch_array($FullRec);
  $UdateAccessQuery = sprintf("UPDATE Members SET access_level = '2' WHERE validation_id =%s", $validation_id);
  mysql_query($UdateAccessQuery, $database name here) or die(mysql_error());
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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