-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
If you want it as a string value you need to wrap it in quotes. The variable change is irrelevant, I like camel case.
$query = "INSERT INTO `Want` (`id_version`,`id_customer`,`id_have`,`havewant`,`date_created`) VALUES('".$id_version."','".$_SESSION['id_customer']."','".$id_have."','".$havewant."','".$created."')";
-
That means there's an error in your query.
Change:
$result_all = mysql_query($query_selectall);
To:
$result_all = mysql_query($query_selectall) or die(mysql_error());
-
<?php $id_have = 23; $id_want = 45; $haveWant = $id_have . "-" . $id_want; var_dump($haveWant); // results: string(5) "23-45" ?>
-
You need to call session_start() on the check login script, that's where you would initialize those session variables.
edit: On the top of the file, not in the if statements.
2nd edit: You're redefining the variables on each page setting the session variables to variables that have no initialization.
Get rid of
$_SESSION['login']; $_SESSION['rank']; $_SESSION['loggedinusername'] = $loggedinusername; $_SESSION['loggedinuseremail'] = $loggedinuseremail;
On the top of each file, it does nothing but set the sessions to blank values.
And as a suggestion, there's no reason to sanitize passwords if they're being encrypted. Somebody's password could be "\\\\/a/s\asnc//" and using stripslashes on it would cause it to be "\/a/sasnc//" before encryption.
-
The second query on the page is overwriting your query. Just comment out this patch of code:
<?php //$query_selectAllItems = "SELECT *, DATE_FORMAT(workshop_date, '%e-%m-%Y') as 'my_date' FROM tbl_workshops"; $query_selectAllItems = "SELECT * FROM tbl_registration"; $result_all = mysql_query($query_selectAllItems); $numRows_all = mysql_num_rows($result_all); ?>
You would obviously be getting the same data because:
while ($c_row = mysql_fetch_array($result_all)){
is going to be corresponding to the latest data stores in the $result_all variable.
-
$links = array ('http://www.php.net/styles/site.css', 'http://www.example.com/styles/some.js', 'http://www.domain.net/styles/hey.php'); $results = array(); foreach($links AS $link){ if(strpos($link, '.css') !== false){ $results[] = $link; } }
-
You need a print statement there.
while($row2 = mysql_fetch_array($result2)) { print "<tr><td>"; print "<a href='editpayment.php?payid=".$row2['PaymentID']."'>".$row2['PaymentID']."</a>"; // the rest of your print statements }
-
-
It really depends on how you want your data to be viewed. You can have a fancy layout or just a simple table.
echo '<table border="0" cellspacing="3" cellpadding="3">'; echo "\n<tr><td>First Name</td>Last Name</td><td>etc...</td></tr>\n"; while($row = mysql_fetch_array($result)){ echo "<tr><td>".$row['first_name']."</td><td>".$row['last_name']."</td><td>".$row['etc']."</td></tr>\n"; } echo "</table>\n";
-
$first = "Bob"; $last = "Marley"; echo $first . "." , (isset($middle))? $middle."." : "" , $last . ".";
Will just print "Bob.Marley." when $middle has no value.
-
Then use what I gave you and what you already have and combine the two. You can use multiple clauses in your SQL select statement.
$sql = "SELECT * FROM `table` WHERE `foo`='bar' AND `bar`='foo'";
-
$toppings = $_POST['toppings']; foreach($toppings AS $key => $value){ echo "Your pizza will have " . htmlentities($value) . " as a topping.<br/>\n"; }
-
$input = mysql_real_escape_string($_POST['event_time']); if($input){ // check if submitted $sql = "SELECT * FROM `events` WHERE `event_time`='".$input."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0){ echo "Time slot has been previously filled. Try again.\n"; }else { echo "Time slot is vacant.\n"; } }else { echo "Please provide a time slot.\n"; }
-
$match = array('W','W','L'); $getAwayR = "Group A"; if($getAwayR == "Group A"){ $numWins = 0; for($i = 0; $i < count($match); i ++){ if($match[$i] == "W" && $numWins < 3){ // whatever else $numWins++; } } }
-
date('h:i:s a')
11:24:15 pm
-
If sessions didn't work for you, you probably didn't do it correctly.
-
Ok, then put all of your code (after the die statement) into the true statement.
if($id != '' && $id > 0){ // all your code that would run }else { // error }
-
$result = mysql_query($query) or die(mysql_error());
Error in the query will cause numrows to throw an error.
-
Well $errors is an Array, so all you're doing is echoing the object. You gotta echo out each individual error.
echo implode("<br/>",$errors);
-
That's more of a full-on user system than just a login system.
-
-
Don't suppress your errors...
$r = mysqli_query($dbc,$q) or die(mysqli_error());
-
Define "admin rights"
-
Looks like Joomla.
Life of a Session
in PHP Coding Help
Posted
works as well.