|
Can anyone tell me what I am doing wrong? I am getting an error message on line 9 (Locid)...
Create table Course_Section
(
Csecid NUMBER(8) CONSTRAINT PK_COURSE_SECTION PRIMARY KEY,
Cid NUMBER(6) NOT NULL CONSTRAINT FK_COURSE_SECTION REFERENCES COURSE(Cid),
Termid NUMBER(5) NOT NULL CONSTRAINT FK_COURSE_SECTION REFERENCES TERM(Termid),
Secnum NUMBER(5) NOT NULL,
Fid NUMBER(4) CONSTRAINT FK_COURSE_SECTION REFERENCES FACULTY(Fid),
Day VARCHAR(10)
Locid NUMBER(5) CONSTRAINT FK_COURSE_SECTION REFERENCES FACULTY(Locid),
Maxenrl NUMBER(4) NOT NULL,
Currenrl NUMBER(4) NOT NULL,
);
|
|
|
|
|
|
You have missed the , above the Locid try this hope this will help you.
|
|
|
|
|
Hi,
I have a PHP project with login session and I would like to ask how can I expire the session automatically after x Time when the application is idle just like GoDaddy and many other websites?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
You can run a little ajax call to a server side function every minute or so to check that the session is still active, and logout or redirect the user if not.
|
|
|
|
|
I have a dropdown list populated with files pulled from a directory using the PHP listed below and am trying to figure out how I can delete them using a delete button in the form when they're selected.
<input type="hidden" name="Action" value="EDIT" /><input type="hidden" name="Selection" id="Selection" value="-1"><div>Below is the list of your saved codes. To edit your codes, select it from the list.</div>
<select size="1" name="CodeList" id="CodeList">
<?php
$directory = $directory = 'users/' . $_SESSION['username'];
$filesContents = Array();
$files = scandir( $directory ) ;
foreach( $files as $file )
{
if ( ! is_dir( $file ) )
{
$filesContents[$file] = file_get_contents($directory , $file);
echo "<option>" . $file . "</option>";
}
}
?>
</select>
delete php script.
<?php
session_start();
$directory = $directory = $_SERVER['DOCUMENT_ROOT'] . '/users/' . $_SESSION['username'];
$file_to_delete = $_POST['CodeList'];
if ( unlink ($directory.'/'.$file_to_delete) ) {
echo $file_to_delete . " deleted.";
} else {
echo "Error.";
}
?>
when I try and save I get the Warning: unlink(/myhome/root/public_html/users/Addiction/) [function.unlink]: No such file or directory in /home/revo/public_html/evo/avdeleteprocess.php on line 5 Error.
So its found the right folder, just not finding the file from the dropdown list selection.
Also edited to add I ran a var_dump($_POST) right after my delete script to see what it was pulling as the value of POST and it came back with: Error.array(1) { ["Action"]=> string(6) "Delete" }
|
|
|
|
|
Not sure if this is relevant but in the first case you have
$directory = $directory = 'users/' . $_SESSION['username'];
and in the second you have
$directory = $directory = $_SERVER['DOCUMENT_ROOT'] . '/users/' . $_SESSION['username'];
Should they not be the same?
|
|
|
|
|
I was just attempting to see if the issue was finding the location and the second one was copied from earlier code. They're both the same now but doesn't have any bearing it seems on finding the file I'm looking for from the dropdown ist.
|
|
|
|
|
Well you can easily display both paths and the relevant filenames to see if they are correct.
|
|
|
|
|
Dear php gurus,
This is my second post on this php forum. Not much luck with my first post.
First, please bear with me as this code is rather long.
I have this dropdown dynamically populated from SQL Server database. The code below is derived from VIEW -> SOURCE
<select name="SType">
<option value=""></option>
<option value="Bid" name="Bid">Bid[2]</option>
<option value="Lib CM" name="Library CM">Lib CM[23]</option>
<option value="Quote" name="Quote">Quote[20]</option>
<option value="RFP" name="RFP">RFP[2]</option>
<option value="Removed" name="Removed">Removed[29]</option>
<option value="Archived" name="Archived">Archived[4501]</option>
<option value="Awarded" name="Awarded">Awarded[40]</option>
<option value="Open" name="Open">Open[47]</option>
<option value="Closed" name="Closed">Closed[11]</option>
<option value="Under Review" name="Under Review">Under Review[126]</option>
<option value="Cancelled" name="Cancelled">Cancelled[64]</option>
</select>
When a user selects any value, say Bid, we would like to display all records associated with Bid. In this case, it will be two records.
The long code below (sorry again), works perfectly in terms of displaying records.
However, when I tried to integrate the code that displays records based on dropdown value, I expected to see just those records.
Instead, it displays all records.
Can you please see what I am doing wrong?
First the code that should display records based on dropdown selection, followed by the long code I am trying to integrate it with.
Your help and understanding very much appreciated.
if(isset($_REQUEST['Solicitations'])){
if($_GET['Solicitations'] == "Bid"){
$result = "SELECT * FROM bids where BidStatus = 1 and BidType = 'Bid' ORDER BY title";
$query = sqlsrv_query( $conn, $sql , $params, $options );
}
}
= array(
= preg_replace(= str_replace(= array(
= array('field' => 'b.BidTitle', 'searchType' => 'like'),
'BidType' => array('field' => 'b.BidType', 'searchType' => 'equal'),
'BidStatus' => array('field' => 'b.BidStatus', 'searchType' => 'equal'),
'department' => array('field' => 'b.Department', 'searchType' => 'equal'),
'bidId' => array('field' => 'b.BidID', 'searchType' => 'equal'),
'bidDate' => array('field' => 'b.BidDate', 'searchType' => 'equal'),
'dueDate' => array('field' => 'b.DueDate', 'searchType' => 'equal')
);
$where = array();
foreach($fields as $fieldPost => $field) {
if(isset($_POST[$fieldPost]) && strlen($_POST[$fieldPost]) > 0) {
if($field['searchType'] == 'like') {
$where[] = "".$field['field']." LIKE '%" . ms_escape_string($_POST[$fieldPost]) . "%'";
} else {
$where[] = "".$field['field']." = '" . ms_escape_string($_POST[$fieldPost]) . "'";
}
}
}
$sql = "Select b.ID,convert(char(10),b.BidDate,101) BidDate,convert(char(10),
b.DueDate,101)DueDate,b.BidTitle,b.DueTime,b.BidID,BidIDFile,
d.Department,b.BidType,CASE WHEN b.AwardDate ='01/01/1900' Then NULL ELSe convert(char(10),b.AwardDate,101)END AS AwardDate,
convert(char(10),b.LastUpdate,101) LastUpdate,s.Status
FROM bids b inner join dept d on b.Department=d.DeptID inner join Status s on b.BidStatus=s.StatusId " . ( count($where) > 0 ? " WHERE " . implode(' AND ', $where) : "" );
//echo $sql;
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$query = sqlsrv_query( $conn, $sql , $params, $options );
$num_rows = sqlsrv_num_rows($query);
$per_page = 20; // Per Page
$page = 1;
if(isset($_GET["Page"]))
{
$page = $_GET["Page"];
}
$prev_page = $page-1;
$next_page = $page+1;
$row_start = (($per_page*$page)-$per_page);
if($num_rows<=$per_page)
{
$num_pages =1;
}
else if(($num_rows % $per_page)==0)
{
$num_pages =($num_rows/$per_page) ;
}
else
{
$num_pages =($num_rows/$per_page)+1;
$num_pages = (int)$num_pages;
}
$row_end = $per_page * $page;
if($row_end > $num_rows)
{
$row_end = $num_rows;
}
$sql = " SELECT c.* FROM (
SELECT ROW_NUMBER() OVER(ORDER BY ID) AS RowID,ID,convert(char(10),b.BidDate,101) BidDate,convert(char(10),
b.DueDate,101)DueDate,b.BidTitle,b.DueTime,b.BidID,BidIDFile,
d.Department,b.BidType,CASE WHEN b.AwardDate ='01/01/1900' Then NULL ELSe convert(char(10),b.AwardDate,101)END AS AwardDate,
convert(char(10),b.LastUpdate,101) LastUpdate,s.Status
FROM bids b inner join dept d on b.Department=d.DeptID inner join Status s on b.BidStatus=s.StatusId " . ( count($where) > 0 ) ? " WHERE " . implode(' AND ', $where) : " )
) AS c
WHERE c.RowID > $row_start AND c.RowID <= $row_end
$query = sqlsrv_query( $conn, $sql);
";
?>
<table>
<thead>
<tr style="white-space:nowrap">
<th></th>
<th>Issue Date</th>
<th>Due Date</th>
<th>Project Title</th>
<th>ID</th>
<th>Department</th>
<th>Type</th>
<th>Award Date</th>
<th>Last Update</th>
<th>Status</th>
</tr>
</thead>
= sqlsrv_fetch_array($query,
<tbody>
="background:',(($c=!$c)? '#eee' : '#ddd' ),';font-size:12px;"'; ?>
<td><div align="center"><a href="bidDetails.php?Id=<?php echo $result["ID"];?>"><img src="images/details.gif" alt="" title="Details" /></a></div></td>
<td><div align="center"></div></td>
<td><br />@</td>
<td><a href="uploads/<?php echo $result["BidIDFile"]; ?>" Target="DETAILS" onClick="window.open('','DETAILS','width=850,height=700,scrollbars=yes'); return true;" type="application/octet-stream"></a></td>
<td style="white-space:nowrap"><div align="center"></div></td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
</tr>
</tbody>
</table>
<br>
Total Record : Page :
='$_SERVER[SCRIPT_NAME]?Page=$prev_page&txtKeyword=$strprojectTitle&BidType=$strbidType'<< Back</a> ";
}
for($i=1; $i<=$num_pages; $i++){
if($i != $page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$strprojectTitle&BidType=$strbidType'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($page!=$num_pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$next_page&txtKeyword=$strprojectTitle&BidType=$strbidType'>Next>></a> ";
}
sqlsrv_close($conn);
?>
|
|
|
|
|
From the select tag, from my own observation, it appears that you have called the wrong tag "name" from the dropdown.
Instead of
if($_GET['Solicitations'] == "Bid")
Since the "select name ="SType" ", why not use
if($_GET['Stype'] == "Bid") . I think that is where the mistakes comes from. Because it is whatever value you select from the dropdown that becomes the value of the Select tag.
|
|
|
|
|
|
I set up a bootable USB stick drive (call it Stick #1) and loaded it up with ubuntu 14.04 LTS, and then booted up with it (using the "try" option), but I can't seem to get another FAT32 formatted (call it Stick #2) recognized. All I want to do is to copy some of the files off of Stick #2 onto the system hard drive (which shows up as "main"). Thanks
|
|
|
|
|
Hi i have a problem with my shopiing cart i hope you can help me with my problem.
I have a shopping cart which contains a session that i get when selecting values on database.
I have also a textbox which contains a desired budget.
My problem is I want to have a error message which can detect if the total price of the session is greater than the budget.
here is my code I hope you can help me
<form method="get">
<table>
<tr>
<td style="padding:5px;">Budget:</td>
<td style="padding:5px;"><input type="text" name="budget" class="txtfield" placeholder="Please enter your desired budget"></td>
</tr>
<tr>
<td style="padding:5px;">Service Type:</td>
<td style="padding:5px;">
<select name="servicetype" class="txtfield">
<option>Wedding</option>
<option>Debut</option>
<option>Birthday</option>
</select>
</td>
</tr>
<tr>
<td style="padding:5px;"></td>
<td style="padding:5px;"><input type="submit" name="search" value="Search" class="btn btn-warning"></td>
</tr>
</table>
</form>
<?php if(isset($_GET['search'])):?>
<h3 style="background:red; color:white; width:300px; padding:5px;">Desired Amount: <?php echo $_GET['budget'] ?></h3>
<?php endif?>
<div class="products">
<?php
$current_url = base64_encode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
if(isset($_GET['search']))
{
$servicetype = $_GET['servicetype'];
if($_GET['budget'] =="")
{
echo'<div class="alert alert-warning">Please enter your desired amount</div>';
}
else
{
$servicetype = $_GET['servicetype'];
$results = $mysqli->query("SELECT service_inclusion,price,servicetype,soid FROM service_offer
where servicetype='$servicetype' ORDER BY soid ASC");
if ($results)
{
while($obj = $results->fetch_object())
{
echo '<div class="product">';
echo '<form method="get" action="cart_update.php">';
echo '<div class="product-content"><h3>'.$obj->service_inclusion.'</h3>';
echo '<div class="product-desc">Price: '.$currency.$obj->price.' </div>';
echo '<div class="product-desc">Service Type: '.$obj->servicetype.' </div>';
echo '<div class="product-info">';
echo '<button style="background:#F01818; color:white;border:0;">Add Services</button>';
echo '</div></div>';
echo '<input type="hidden" name="service_inclusion" value="'.$obj->service_inclusion.'" />';
echo '<input type="hidden" name="type" value="add" />';
echo '<input type="hidden" name="soid" value="'.$obj->soid.'" />';
echo '<input type="hidden" name="return_url" value="'.$current_url.'" />';
echo '</form>';
echo '</div>';
}
}
}
?>
</div>
<div class="shopping-cart">
<h2>Your Shopping Cart</h2>
<?php
if(isset($_SESSION["products"]))
{
$total = 0;
echo '<ol>';
if($_GET['budget'] > $cart_itm['price'])
{
$message = 'error';
}
else
{
foreach ($_SESSION["products"] as $cart_itm)
{
echo '<li class="cart-itm">';
echo '<span class="remove-itm"><a href="cart_update.php?removep='.$cart_itm["code"].'&return_url='.$current_url.'">×</a></span>';
echo '<h3>'.$cart_itm["name"].'</h3>';
echo '<div class="p-price">Price :'.$currency.$cart_itm["price"].'</div>';
echo '</li>';
$subtotal = ($cart_itm["price"]);
$Total = ($total + $subtotal);
}echo'</ol>';
echo '<span class="check-out-txt"><strong>Total : '.$currency.$Total.'</strong> <a href="view_cart.php">Check-out!</a></span>';
echo '<span class="empty-cart"><a href="cart_update.php?emptycart=1&return_url='.$current_url.'">Empty Cart</a></span>';
} }
else
{
echo 'Your Cart is empty';
}}
?>
</div>
<div style="clear:both;"></div>
</div>
<script type="text/javascript">
<?php
if(isset($message))
{
echo "alert('$message')";
}
?>
</script>
modified 13-Feb-15 4:49am.
|
|
|
|
|
You should edit the above question, remove all the code not relevant to the issue, and show exactly where the problem occurs.
|
|
|
|
|
Hi,
the following file has dateFrom and dateTo datepickers:
http://www.mybluefile.com/new_leave.zip[^]
When submitting the form I don't get the correct MySQL format therefore it's throwing an error.
The value I get is something like this:
1423900800
that's when I try:
echo $timestamp = strtotime($_POST['dateFrom']);
can you help please...
Technology News @ www.JassimRahma.com
|
|
|
|
|
strtotime converts a date string to a Unix timestamp: http://php.net/manual/en/function.strtotime.php[^]
php.net says: The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC)
To format the date, use the date function:
$timestamp = strtotime($_POST['dateFrom']);
$formatted_date = date("[format here]", $timestamp);
I don't know which format you want exactly, so you can take a look at the PHP manual to see how you can format your date:
http://php.net/manual/en/function.date.php[^]
The quick red ProgramFOX jumps right over the Lazy<Dog> .
|
|
|
|
|
Hi,
I would like to ask how to convert this C# code into PHP as my office application is in WinForm C# but need to have a PHP portal for it?
public string HashString(string toHash)
{
using (SHA512CryptoServiceProvider sha = new SHA512CryptoServiceProvider())
{
byte[] dataToHash = Encoding.UTF8.GetBytes(toHash);
byte[] hashed = sha.ComputeHash(dataToHash);
return Convert.ToBase64String(hashed);
}
}
public string HashPassword(string password, string salt)
{
string combined = password + salt;
return HashString(combined);
}
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
I am overwriting the session cookie to set different domain names with respect to the protocol(http/https)
i wanted to know whether the following is good comparing to the next
$sessname = session_name();
setcookie($sessname, $_COOKIE[$sessname], ...
vs
setcookie(session_name(), session_id(), ....
which one to use?
|
|
|
|
|
When I upload files to localhost, it runs ok. When I upload to real server and connect to it, here is what I get:
Apache 2.
Apache was not able to cross-connect to remote host.
Ive even reinstalled LAMP. With no luck
|
|
|
|
|
Hi
I am running OpenSuse
I am have flash drive on my laptop which I would like to read the contents.
I am guessing it's one of the SDXX directories in the /dev directory.
I have tried to mount each and every sda device (I have sda, sda1,sda2,sda3) and none of those seem like the flash drive
When I do a lsusb command I can see the device listed as bus 3 device 3
Any help appreciated
Thanks
|
|
|
|
|
ForNow wrote: I have tried to mount each and every sda device (I have sda, sda1,sda2,sda3) and none of those seem like the flash drive
sda will almost certainly be the HDD of you laptop with sda1 being the first partiton and sd12 the second and so on.
I would have a look at sdb and /or sdc. Haven't worked with OpenSuse, but if you're use a GUI you should be able to see the USB drive from one of the graphical programs.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
Hi all,
I have got 4 drop down selection boxes.The idea is to be able to select an item from each selection box,get them strung together in sql string and get the result of the query printed
The problem is I keep getting the following message:
Parse error: syntax error, unexpected '$rs' (T_VARIABLE) in C:\xampp\htdocs\dreamincode.php on line 60
I know the code is not too sophisticated but it's part of a little project I started earlier this year and then got distracted and just managed to get back to it now.
Here is the code in full.Any suggestions greatly appreciated.
<pre lang="xml"><!DOCTYPE HTML>
02 <html>
03 <body>
04
05
06 <select name = "author">
07 <option value="kendavies">ken davies</option>
08 <option value="arthursmith">arthur smith</option>
09 <option value="gillrafferty">gill rafferty</option>
10 <option value="mollybrown">molly brown</option>
11 <option value="gilbert riley">gilbert riley</option>
12 <option value="colinwilson">colin wilson</option>
13 <option value="jamesgreen">james green</option>
14 <option value="arnoldlaing">arnold laing</option>
15 <option value="cathyellis">cathy ellis</option>
16 <option value="carolreed">carol reed</option>
17
18 </select>
19
20 <select name = "publisher">
21 <option value="yonkers">yonkers</option>
22 <option value="blueparrot">blue parrot</option>
23 <option value="zoot">zoot</option>
24
25 </select>
26 <select name = "published">
27 <option value="2003">2003</option>
28 <option value="2004">2004</option>
29 <option value="2005">2005</option>
30 <option value="2006">2006</option>
31 <option value="2007">2007</option>
32 <option value="2008">2008</option>
33
34 </select>
35
36 <select name = "genre">
37 <option value="adventure">adventure</option>
38 <option value="thriller">thriller</option>
39 <option value="crime">crime</option>
40 <option value="biography">biography</option>
41 <option value="romance">romance</option>
42
43 </select>
44 $aa = "author"
45 $bb = "publisher"
46 $cc = "yearpublished"
47 $dd = "genre"
48 </body>
49 </html>
50 <?php
51
52 $aa = "author";
53 $bb = "publisher";
54 $cc = "yearpublished";
55 $dd = "genre";
56 mysql_connect ("localhost","root","") or die(mysql_error());
57 mysql_select_db ("authors") or die(mysql_error());
58
59 $strSQL = SELECT * FROM `books`WHERE author = '".$aa."' AND publisher = '".$bb."' AND yearpublished = '".$cc."' AND genre ='".$dd."'" ";
60 $rs = mysql_query($strSQL);
61
62
63
64 while($row = mysql_fetch_array($rs) ) {
65
66 print $row ['ID']."<br/>";
67 print $row ['author']."<br/>";
68 print $row ['booktitle']."<br/>";
69 print $row ['publisher']."<br/>";
70 print $row ['yearpublished']."<br/>";
71 print $row ['genre']."<br/>";
72 print $row ['copiessold']."<br/>";
73
74
75 }
76 mysql_close();
77 ?>
78 </body>
79 </html>
kind regards
col
|
|
|
|
|
Looks like you are missing the opening double quote before SELECT and a missing space before WHERE . I should go through the syntax for that statement again. You could check the final string by displaying it on the page before you try to execute it.
|
|
|
|
|