-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
http://us2.php.net/pdf
http://sourceforge.net/project/showfiles.php?group_id=45168&package_id=37830&release_id=147645 -
Your problem is probably an un ended form.
-
Before you end your sql queries add WHERE username ='$whateveryourusernamevariableis'
-
What your saying Shogun doesn't mean anything. You aren't deleting anything the person is only updating their username back to their actual username. It would only get deleted if the person had update password to pass where username is username.
-
You need to add in your sql queries
[code]
WHERE username ='$username'
[/code]
You're just updating nothing -
[code]
<?php
$var = "abc";
if(!is_numeric($var)){
$words = ucwords($var);
echo $words;
//will show Abc
}else {
die("bad");
}
?>
[/code]
For all caps:
[code]
<?php
$var = "abc";
if(!is_numeric($var)){
$words = strtoupper($var);
echo $var;
//will show ABC
}else {
die("bad");
}
?>
[/code]
-in school, i rock -
[code]
while($row = mysql_fetch_assoc($result)){
$name = $row[name];
$type = $row[type];
$size = $row[size];
$content = $row[content];
echo "$name<br>$type<br>$size<br>$content";
}
[/code] -
Try echoing off your sessions and see if they are even set. You can always try to change your session expire time.
-
[code]
<?php
$sql1 = "SELECT * FROM `width` WHERE `width` < 5";
$res1 = mysql_query($sql1);
echo "<select name=width>";
while($row1 = mysql_fetch_assoc($res1)){
echo "<option value=$row1[width]>$row[width] inches</option>\n";
}
echo "</select>";
$sql2 = "SELECT * FROM `height` WHERE `height` < 3";
$res2 = mysql_query($sql2);
echo "<select name=height>";
while($row2 = mysql_fetch_assoc($res2)){
echo "<option value=$row[height]>$row[height] inches</option>\n";
}
echo "</select>";
?>
[/code] -
I'm making a restock system and the rows are not being inputted correctly.
[code]
<?php
require('../connect.php');
$min = date("i");
$sql[time] = "SELECT `time` FROM `shops` WHERE `id` =1";
$res[time] = mysql_query($sql[time]);
$rowtime = mysql_fetch_assoc($res[time]);
if($min == $rowtime[time]){
//will have array of items
//insert into time using BLAH
//also update time, if $min > 10 new time will eqaul rand(11,20), if $min > 20, rand(21,30), etc....
}else {
//die();
}
$sql = "SELECT * FROM `list_items` WHERE `type` ='Food'";
$res = mysql_query($sql) or die(mysql_error());
$array = array();
$arra2 = array();
$arra3 = array();
$arra4 = array();
$total = mysql_num_rows($res);
while ($row = mysql_fetch_assoc($res)) {
$array[] = $row['ID'];
$arra2[] = $row['item_name'];
$arra3[] = $row['url'];
$arra4[] = $row['estimate_price'];
}
foreach($array as $val) {
$array = "$val,";
echo "$array";
}
echo "<br>";
foreach($arra2 as $val2){
$arra2 = "$val2,";
echo "$arra2";
}
echo "<br>";
foreach($arra3 as $val3){
$arra3 = "$val3,";
echo "$arra3";
}
echo "<br>";
foreach($arra4 as $val4){
$arra4 = "$val4,";
echo "$arra4";
}
$num = rand(1,$total);
for ($i = 0;$i <= $num; $i++){
if (mysql_query("INSERT INTO `shopstock` (`itemid`,`item_name`,`url`,`price`) VALUES ('$array[$i]','$arra2[$i]','$arra3[$i]','$arra4[$i]');")) {
echo $array[$i]." inserted";
}
}
?>
[/code]
Basically I get:
Full Texts id itemid item_name url price stock place
Edit Delete 1 2 Y h 3 0
Edit Delete 2 2 u t 0 0
Edit Delete 3 5 c t 1 0
Edit Delete 4 0 k p 0 0
Edit Delete 5 0 y : 0 0
Edit Delete 6 0 / 0 0
Edit Delete 7 0 R / 0 0
Edit Delete 8 0 i w 0 0
Edit Delete 9 0 c w 0 0
Edit Delete 10 0 e w 0 0
Edit Delete 11 0 , . 0 0
Edit Delete 12 0 t 0 0
Edit Delete 13 0 e 0 0
dont worry about place. -
[code]
$sql = "SELECT * FROM `list_items` WHERE `type` ='Food'";
$res = mysql_query($sql) or die(mysql_error());
$array = array();
while ($row = mysql_fetch_assoc($res)) {
$array[] = $row['ID'];
}
foreach($array as $val) {
$array = "$val,";
echo $array;
}
[/code]
Is what I'm trying to do is to have an array ($array) probably explode it, and then do a random number 1,20 and then take the random number and select that many items from the array, and insert them into the database. -
How would I make it into the array? I don't understand this.
-
[code]
<?php
$sql = "SELECT * FROM `users`";
$res = mysql_query($sql) or die(mysql_error());
echo "<table border=0 cellspacing=3 cellpadding=2>\n";
echo "<tr><td>ID<td>link 1<td>link 2\n";
while($row = mysql_fetch_assoc($res)){
echo '<tr><td>'.$row[id].'<td><a href="profile.php?id='.$row[id].'">$row[username]</a><td><a href="linktwo.php?id='.$row[id].'">$row[whatever]</a>\n";
}
echo "</table>";
mysql_free_result($res);
?>
[/code] -
That's pretty simple.
If you use cookies:
[code]
<?php
//stuff available to everyone here
if(isset($_COOKIE['logged'])){
//add my account logged in only stuff here
}
?>
[/code]
For sessions:
[code]
<?php
//stuff available to everyone here
if(isset($_SESSION['logged'])){
//add my account logged in only stuff here
}
?>
[/code]
Just changed logged to whatever your cookie or session is called when the user logs in. -
You can do some if functions with a get variable.
[code]
<?php
$id = $_GET['id'];
//id will be a page in the folder inc, $id.inc
if(!isset($id)){
include('inc/index.inc');
}else {
if(!file_exists("inc/$id.inc")){
echo "The page you are trying to view is not available";
}else {
include("inc/$id.inc");
}
}
?>
[/code] -
That happens when I try to echo it off.
-
Fatal error: Cannot use [] for reading in /home/kael/public_html/rs_cron/food.php on line 24
-
That would make it into an array as in array(); ?
-
Just do unset($_COOKIE[name]);
-
How would I make an array out of a while statement
[code]
$sql = "SELECT * FROM `list_items` WHERE `type` ='food'";
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($res)){
$row[item_id];
}
[/code]
and take the while statement stuff and put it into an array -
Well your external drive is obviously going to be like E:\P-files\e-php-1-8\ms\data
-
Probably because you didn't have $tag defined.
-
The database is in localhost, as long as you have both set up and are on the same LAN network it should work just fine.
-
You can see on his website that $tag is not registering.
Try:
[code=php:0]
<?php
switch($_GET['tag']){
//etc...
}
?>
[/code]
Multiple Drop Down Query Help Needed
in PHP Coding Help
Posted
[code]
<?php
$sql = "SELECT * FROM table";
$res = mysql_query($sql);
echo "Width: <select name=width>\n";
while($row = mysql_fetch_assoc($res)){
echo "<option value=$row[width]>$row[width] Inches</option>\n";
}
echo "</select>";
echo "Height: <select name=height>\n";
while($row = mysql_fetch_assoc($res)){
echo "<option value=$row[height]>$row[height] Inches</option>\n";
}
echo "</select>";
?>
[/code]