pocobueno1388
Members-
Posts
3,369 -
Joined
-
Last visited
Never
Everything posted by pocobueno1388
-
[SOLVED] Inserting and Updating Arrays...
pocobueno1388 replied to briant's topic in PHP Coding Help
They would be in a string. Although you can easily change it back to an array if you wanted like this: <?php //we will say this is the variable from the database $friends = $row['friends']; //put them back into an array $friends = explode(" ", $friends); ?> -
[SOLVED] Is it possible to run multiple queries on one page
pocobueno1388 replied to affordit's topic in PHP Coding Help
Yes, you would just do another query. You MAY be able to combine everything you want into one query and get the same results. How are the tables in your database setup? So give a detailed description of your tables, then tell us exactly what your wanting to select. -
Yes it is, but this has nothing to do with PHP, you would use CSS. <style type="text/css"> .bg { background-image: url(background.jpg); background-repeat: repeat-x; ## Or you could set it to repeat "y" to go the other direction } </style>
-
[SOLVED] Inserting and Updating Arrays...
pocobueno1388 replied to briant's topic in PHP Coding Help
Yes, you will still be able to call which name you want from the array by using the key like you did. But Bob would be $friend[2] because the counter starts at 0...here is an example. <?php $names = array("Brian","Billy","Bob","Joe"); 0 1 2 3 Does that make sense? -
[SOLVED] Inserting and Updating Arrays...
pocobueno1388 replied to briant's topic in PHP Coding Help
So you want it to appear in the database in a text field as one line like so? Brian Billy Bob Joe If thats how you want it, then you would do this: <?php $names = array("Brian","Billy","Bob","Joe"); $query = "UPDATE site_table SET friends = '" . implode($names, " ") . "' WHERE user_id = 2" $result = mysql_query($query)or die(mysql_error()); ?> -
[SOLVED] Inserting and Updating Arrays...
pocobueno1388 replied to briant's topic in PHP Coding Help
Here is how you would add a name later on in the script <?php $names = array("Brian","Billy","Bob","Joe"); //Add a name $names[] = "Cindy"; ?> As for your query question, I would need to see how you had your database table setup to know how to insert the information. -
Try this <?php include("dbinfo.inc.php"); mysql_connect(mysql,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $default_event= array('event1', 'event2'); if(isset($_REQUEST['changed']) && count($_REQUEST['changed']) > 0 && !empty($_REQUEST['command'])) { $sql = ""; $insql = "IN('" . join("','",array_keys($_REQUEST['changed'])) . "')"; switch($_REQUEST['command']) { case "Deactivate": $sql = "UPDATE birthdays SET ACTIVE='0' WHERE id " . $insql; break; case "Activate": $sql = "UPDATE birthdays SET ACTIVE='1' WHERE id " . $insql; break; case "Delete": $sql = "DELETE FROM birthdays WHERE id " . $insql; break; } if(!empty($sql)) { mysql_query($sql); } } $where = $url = array(); if(!empty($_REQUEST['event'])) { $where[] = "Event='" . addslashes($_REQUEST['event']) . "'"; $url[] = "event=" . $_REQUEST['event']; } else { $num_of_events = count($default_event); for($i=0; $i<$num_of_events;$i++){ if ($i == 0) $where[] = "Event='$default_event[$i]'"; else $where[] = " OR Event='$default_event[$i]'"; } $_REQUEST['event'] = $default_event; } if(strlen($active) > 0) { $where[] = "Active='" . addslashes($_REQUEST['active']) . "'"; $url[] = "active=" . $_REQUEST['active']; switch($active) { case 1: $page_type = "ACTIVE"; break; case 0: $page_type = "INACTIVE"; break; } } else { $page_type = "ALL"; } $query="SELECT * FROM birthdays"; if(count($where) > 0) { $query .= " WHERE " . join(" AND ",$where); } $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<A name=\"top\"></A><b><center><H1>Display Records \"<I>$page_type $default_event records</I>\":</H1>"; ?> On this line $default_event= array('event1', 'event2'); You can add as many events as you would like to the array. The code is untested, so hopefully it will work.
-
[SOLVED] Query by dates in between dates, better way than this?
pocobueno1388 replied to djones's topic in MySQL Help
Try WHERE CURDATE() BETWEEN s_date AND e_date -
Well, if it works then thats fine. Or you could do it this way <?php $ut= strtotime("+1 week"); echo date("Y-m-d", $ut); ?>
-
For your first question <?php //Unix Timestamp $time = time(); //Convert $date = date("Y-m-d g:i", $time); echo $date; ?> And for your second: <?php //Unix Timestamp $time = time(); //Convert and add 7 days $date = date("Y-m-d g:i", strtotime("$date + 7 DAY")); echo $date; ?>
-
is using msql_fetch_array without a while loop possible?
pocobueno1388 replied to tet3828's topic in PHP Coding Help
No, I completely agree with you. The method you suggested would probably be better. That way you get the third row whether the data is corrupted or not in the DB. So that was a great thought -
We can't tell you whats wrong if you don't tell us the exact problem.
-
is using msql_fetch_array without a while loop possible?
pocobueno1388 replied to tet3828's topic in PHP Coding Help
Well, I was logically thinking that the row with an ID number of 3 WOULD be the third row. I suppose it could be different. -
is using msql_fetch_array without a while loop possible?
pocobueno1388 replied to tet3828's topic in PHP Coding Help
If all you want is the third row, why not just adjust your query? I'm assuming you have some sort of auto-incremented row, we will call that "id". SELECT * FROM table_name WHERE id=3 -
You needed to wrap the "explor.php" in quotes.
-
is using msql_fetch_array without a while loop possible?
pocobueno1388 replied to tet3828's topic in PHP Coding Help
Without a while loop it is only going to show the first result. Is the "GeoLoc" field in your DB empty for the first result? You might want to check that out. -
$page = $_SERVER['PHP_SELF']; echo $page;
-
Okay, try this and make sure the variables are coming out right. <?php $query = "UPDATE event SET eventName = '{$eventn}', TicketsOnSale = '{$ticknum}', TicketPrice = '{$tickp}' WHERE eventid = '{$menu}'"; $result = mysql_query($query)or die(mysql_error() . "<p>With Query:<br>$query"); echo "<p>$query"; ?>
-
Put a die statement on the query. $result = mysql_query("UPDATE event SET eventName = '{$eventn}', TicketsOnSale = '{$ticknum}', TicketPrice = '{$tickp}' WHERE eventid = '{$menu}'")or die(mysql_error());
-
[SOLVED] Parse error: syntax error, unexpected ';'
pocobueno1388 replied to Dada78's topic in PHP Coding Help
You didn't for the next line down as well. -
[SOLVED] Parse error: syntax error, unexpected ';'
pocobueno1388 replied to Dada78's topic in PHP Coding Help
You didn't close the parenthesis. $email = mysql_real_escape_string($_POST['email']); -
[SOLVED] if folder already exists then display error message?
pocobueno1388 replied to A2xA's topic in PHP Coding Help
Only put the code to create the file between the else statement brackets. <?php if (file_exists($dir)) { echo "The hub $dir exists already"; } else { //Put code to create file here echo "Hubs Sucessfully Added, Your Hub ID is "; echo "$dir"; } -
[SOLVED] if folder already exists then display error message?
pocobueno1388 replied to A2xA's topic in PHP Coding Help
Look at the file_exists() function. -
Thats exactly what it does...did you change the code I gave you?
-
[SOLVED] HELP: PHP upgrade broke my code!
pocobueno1388 replied to steveg1701's topic in PHP Coding Help
First try this: <?php function NextOrder($OrderID) { ConnectDatabase(); $MyQuery = "SELECT OrderID FROM `Orders` WHERE (OrderID > $OrderID)"; $request = mysql_query($MyQuery); list($Answer) = mysql_fetch_row($request); echo "DEBUG: Query is '$MyQuery', next is '$Answer'"; return $Answer; } ?> If that doesn't work, try this: <?php function NextOrder($OrderID) { ConnectDatabase(); $MyQuery = "SELECT OrderID FROM `Orders` WHERE (OrderID > $OrderID)"; $request = mysql_query($MyQuery); $row = mysql_fetch_assoc($request); $Answer = $row['OrderID']; echo "DEBUG: Query is '$MyQuery', next is '$Answer'"; return $Answer; } ?>