181 Posted Topics
Re: Ahh! Use code tags please! You problem is the first couple characters: ''1. The single-quote starts a string and ends a string, then you have a number after it. Did you mean: '1' or '', 1? Both of these are valid SQL, but to be sure, can we see the … | |
Re: There is no shorter way to ensure that several fields aren't blank in SQL, but you could write a PHP function to make it slightly easier: [code=PHP] function selectWhereNotNull($fields, $table, $where) { //Init Query $query = "SELECT "; //Append fields to Select if(is_array($fields)) { $query .= implode(", ", $fields); } … | |
Re: No, and I wouldn't have a clue to why this belongs in the PHP forum on DaniWeb. Are you possibly looking for mafia wars on Facebook? Maybe just try Googling "Online Mafia Game". | |
Re: Could you please use clear English? I'm not quite sure what you are asking. Make sure you elaborate on the details of your problem including how to reproduce the problem and what exactly happens. | |
Re: [QUOTE=Wraithmanilian;1137095]Please use the code tags in future posts to enclose your code in. :)[/QUOTE] You can say that again! To check for a valid AID, try querying for all records with that id and then counting the number of rows returned: [code=PHP] $result = mysql_query("SELECT AID FROM Employeeinfo WHERE AID='".mysql_real_escape_string($aid)."' … | |
Re: The problem is with your MySQL. Try quoting the values you are inserting. Also, on a side note, instead of using session you could use hidden inputs to pass the required values to form_process.php. Though it won't make much of a difference, substituting another technique in place of session saves … | |
Re: Nope you need AJAX (JavaScript to do this). PHP is server side. Javascript is clientside. Serverside code is long completed when you see the final output. There would be no way to perform a query without calling a script on the server with AJAX. Sorry to disappoint. But if you … | |
Re: Inside a complex syntax brackets ([icode]{$var}[/icode]) you can call any function with a return value that can be converted to casted to a string. So using your code that would be: [code=PHP] $message .= "<td>XXXX-XXXX-XXXX-{substr($_GET['cc_number'] , -4, 4)}</td>"; //Or this.... $message .= "<td>XXXX-XXXX-XXXX-".substr($_GET['cc_number'] , -4, 4)."</td>"; //Or even this... $message … | |
Re: So you want to reply to send back to AJAX the exact content that AJAX sent through post? That seems kind of pointless to me, unless you want to do something to the data first (like search for it in a DB). In that case do this: [b]demo_insert.php:[/b] [code=PHP] //Use … | |
Re: What you are looking for is file writing/reading operations. For this you use fopen along with the w parameter which tells PHP you want to write to the file (and create it if it doesn't already exist). [code=PHP] $name = $_GET['name']; //Or where-ever you get the file name //Sanatize $name … | |
Re: Try restarting your machine. I find (On Windows, though, not Ubuntu) that even if I restart apache, the php.ini doesn't update until after a restart. | |
Re: What's between the parenthesis of the switch statement? I think what you are looking for is: [code=PHP] <!doctype html> <html> <head> <title>Input Name Test</title> </head> <body> <?php if(isset($_POST['submit'])) { switch($_POST['submit']) { case "Delete": mysql_query("DELETE FROM UserSites WHERE SiteNumber=".mysql_real_escape_string($_POST['SiteNumber']); echo 'Site Deleted!<br>'."\n"; break; case "Other Action": //Other actions can be added … | |
Re: Just a note: When you find the number of pages, you want to find the ceiling (or highest integer) of the division since 1.5 of a page is actually two. [code=PHP] $pages = ceil($item_count / $per_page); [/code] Also, does the error message (notice) given you a line number? | |
Re: Just so you know, you cannot add headers after the first character (outside the PHP tags) has been written. Also, a few of your CSS properties will throw up some errors. I also noticed that you use javascript to submit your form. This doesn't seem necessary (You can set the … | |
Re: Every 15 seconds? That's a really short interval! It seems like this would add a constant load on the server (therefore taking processing power away from user requests). I suggest you stick to a bit longer of an interval, maybe 10 minutes? But to create a loop with a delay... … | |
Re: Well there's SWF charts that rely on XML files for data. You could make the XML file dynamic with PHP and have the SWF poll the file every fifteen seconds or so. [URL="http://www.maani.us/xml_charts/"]XML/SWF Charts[/URL] would be an option for this. The other way, would be with Javascript and CSS. Sometime … | |
Re: But if the form submits data to post, then yes, it wouldn't work. But slightly modified it will: [code=HTML] onclick="javascript: document.form.currency.value='euro'; document.form.action=\"index.php?currency=euro\"; document.form.method=\"get\"; document.form.submit();" [/code] Or you could do this: [code=PHP] <?php session_start(); if (isset($_GET['currency']) && !empty($_GET['currency'])) { $_SESSION['currency']=$_POST['currency']; $v=explode('?','http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],2); $v[1]=str_replace('currency='.$_GET['currency'],'',$v[1]); $v[1]=trim(str_replace('&&','&',$v[1]),'&?'); $j=$v[0]; $j.=(empty($v[1]))?'':'?'.$v[1]; header('Location: '.$j); exit; } [/code] (If … | |
Re: The problem is that C:\Documents and Settings\Sando\Desktop\boys.gif is a file on your desktop. It works on localhost, because that file exists on your desktop. You need to upload the boys.gif file to Bluehost and change the line that opens that file. [b]EDIT (AFTER EXAMINING YOUR CODE FURTHER)[/b] Just wondering, are … | |
Re: To display the username and display name all you need to do is use [icode]get_currentuserinfo()[/icode]: [code=PHP] <?php //Declare a global to hold the user's username and display name global $user_login, $display_name; //Get the user's information get_currentuserinfo(); //Then display a welcome message echo "<strong>Welcome back {$display_name} ({$user_login})!</strong>" ?> [/code] Use the … | |
Re: Well your problem is here: [code=PHP] if (!in_array($dirArray[$i],$fileName_database['filename'])){ [/code] The first parameter of the [icode]in_array()[/icode] function should be the value to seach for, the second, the array: [code=PHP] if (!in_array($fileName_database['filename'],$dirArray)){ [/code] [b]EDIT:[/b] To fix the other problem on line 48: [code=PHP] if (!in_array($fileName_database['filename'],$dirArray)){ [/code] Wait, this might not work. Let … | |
Re: Well you could create a form and when the admin submits it, update the movie status with a MySQL query: [b]status.php[/b] [code=PHP] <html> <head> <title>Rental Demo - Created By PhpMyCoder</title> </head> <body> <?php if(isset($_POST['submit'])) { if($_POST['movie1']==1) mysql_query("UPDATE movies SET available='1' WHERE name='movie1'"); else mysql_query("UPDATE movies SET available='0' WHERE name='movie1'"); } … | |
Re: Well the first thing I see is you need an end quote in the first line (You also need to research the first function, mysql_connect: its host, username, password): [code=PHP] $con = mysql_connect('HOST', 'USERNAME', 'PASSWORD') OR die("Error: ".mysql_error()); [/code] You also have a problem with your protect function. Use the … | |
Re: Alright, it's done! You can download the demo from: [URL="http://files.phpmycoder.net/da0110v"]http://files.phpmycoder.net/da0110v[/URL] | |
Re: Well, let me ask the simple question: Does GD work? Can you make a simple image with it or does it fail to initialize? | |
Re: [QUOTE=daryll1;1092113] If anyone has any ides this would be amazing as it would save me having to write an if statement for each puzzle. Daryll[/QUOTE] Since there are multiple puzzles, a switch statement would probably be a better option (It's a bit less than an if, but I guess you … | |
Re: I don't think PHP is the appropriate language for this. This project might be a bit beyond it's capabilities. The best I could do with PHP is maybe write some JavaScript to use the Google Maps API. Why re-invent the wheel, when Google has perfected it. I'm sure with the … | |
Re: Ahh...funny enough I did something similar as one of my first large PHP projects. The code I wrote back then was quite atrocious, but its gotten better :P. It was pretty straightforward then, but if at all possible, I would use OOP. Like you said, you only need a backend … | |
Re: Well why not look into the [icode]$_GET[/icode] and [icode]$_POST[/icode] superglobals of PHP. They will allow you to display and work with form data submitted by a user. Try: [URL="http://www.w3schools.com/php/php_forms.asp"]W3Schools PHP Forms[/URL] If you could elaborate on what you want each of the textfields on confirmreserve.php to contain, I can give … | |
Re: Well, I'm assuming your a beginner to PHP. This would be like asking a small child to launch a rocket to the moon and back. Can it be done...yes, but I think you should try immersing yourself in PHP and learning about the language before your try something ambitious. Never-the-less, … | |
Re: Do the values in MySQL have a # before the color hex (or if it's rgb, is there a [icode]rgb( )[/icode] surrounding the pair of numbers)? | |
Re: How about including a PHP file which contains the javascript you wish to be able to access the PHP variables. Then in this included file pass the PHP variables to the script. You can not alter a PHP variable from javascript, but this should suffice. Here's an example: [b]index.php:[/b] [code=php] … | |
Re: Have you tried an OOP approach. I use an OOP paginator on my site, and I usually find OOP much easier to use. Why not try creating a class to hold a result and then create an array of the result objects. You can figure page numbers by using [icode]ceil(count($resultArray)/$itemsPerPage)[/icode]. … | |
Re: Why not pre-load some data instead of using AJAX. It makes much more sense to me, but if you insist, have you checked out [URL="http://www.w3schools.com/PHP/php_ajax_intro.asp"]W3SChools AJAX tutorial[/URL]? Here's a little demo of what you're looking for: [code=javascript] function getPopulation(country) { ajax = getAjax(); if(ajax) { ajax.onreadystatechange = function() { alert(country."'s … | |
Re: If I'm not mistaken, Google frowns upon the checking of page ranks like this. They might have prevented your site from checking. My guess is that your PHP does not allow sockets, but there could be another reason. | |
Re: Assuming the file you posted is called z_register_parse.php, I would guess that the error is inside z_join_form.php. It's probably a missing PHP end tag [icode]?>[/icode], but it could also be a missing bracket or other non-terminated statement. Post your code for this file and we can tell you the exact … | |
Re: [QUOTE=sinnerFA;1088760]You cannot get an external MAC address of a user without having local LAN access to them... UNLESS: you have access to a good ARP table and only if the client is connected DIRECTLY to the php server (if there are routers/gateways that NAT the traffic, the returned MAC address … | |
Re: As Shawn said, what you are looking for is a technique used in many programming languages called passing by reference. Instead of giving the function the value the variable, the place where the variable is stored in memory is given so that function is free to edit the variable (or … | |
Re: Well by simple logic, why not assume that one unique view is viewing the first page of an article. If so, why not just count the unique views on the first page of each article. [b]A note about search engine bots:[/b] Most search engines identify themselves with a special HTTP … | |
Re: Well the first problem is you didn't specify a type of input. This isn't the main problem, but causes the document to be an invalid (X)HTML page. I will look more into your problem and see what the real cause of it is... EDIT: I notice that in the first … | |
Hi Everyone, I was just coding a small mockup example from someone on the PHP forum and it just occurred to be that DaniWeb's code tags will only highlight in one language (To my knowledge). This is somewhat annoying since most PHP files can contain HTML and only one can … | |
Re: The first step would be to get the server side of your request programmed. This will mean you would need knowledge in a language such as PHP, ASP, or JSP. If you already have a backend coded, the next step would be the javascript frontend. For this you will need … | |
Re: 1. Notepad++ or Dreamweaver (I know! But for some reason I have stuck with it) 2. Well I use my own PHP libraries for handling MySQL and I prefer jQuery, but I'm also working on my own JS library! 3. None! Hate frameworks! They make things way too complicated (Besides, … | |
Re: Try this..you need some quotes (You also need a form action..which can be easily fixed by PHP_SELF which will insert the name of the current PHP page): [CODE=php] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <?php $a = $_POST['1']; … | |
Re: [QUOTE=Noaim Sirfgame;1080203]Hi Orkut team, I am sorry about upload nudity images in my orkut account, I was not knowing about your terms and conditions. So, I request you to please reactivate my orkut account so that I can delete that nudity photos from my account and promise you that I … | |
Re: It's probably a missing header, IE is always picky! One thing to note though if what if I was a user and I entered "htdocs/index.php" or "www/index.php"? With some luck you script would print out the code stored inside the index.php file (The browser would confuse it for a PDF, … | |
Re: In PHP it's fairly simple to connect to your MySQL database: [code=PHP] //Start by connecting to the database or die showing MySQL Error mysql_connect("localhost", "USERNAME", "PASSWORD") or die(mysql_error()); //Next select the database or die again showing the MySQL error mysql_select_db("DATABASE NAME") or die(mysql_error()); $result = mysql_query("SELECT * FROM query"); //Perform … | |
Re: Looks like your dealing with WordPress! I'm not sure how you can get the [icode]is_sticky()[/icode] outside of the have posts loop. The only thing I can think of is using absolute positioning in CSS and creating a table where the [icode]is_sticky()[/icode] is and then position it at the top of … | |
Re: Well first I see a [b]huge[/b] gaping security hole! Never, never use a variable for the table name (Unless the user has no control over this variable, meaning nowhere is it set from a [iCODE]$_GET,[/iCODE] [iCODE]$_POST[/iCODE], or [iCODE]$_REQUEST[/iCODE] value). I would also escape all variables with [iCODE]mysql_real_escape_string()[/iCODE]. Beyond that, this … | |
Re: [i]Man[/i], I think he means maybe using some AJAX to fetch results instead of having to request a new page. For that one, you would need to see the JavaScript forum, [i]man[/i]! :D To get you started here's an idea: [code=html] <a href="#?s=5" onclick="nextPage(5);">Next Value</a> [/code] See: [URL="http://www.w3schools.com/js/default.asp"]W3Schools JavaScript[/URL] [URL="http://www.w3schools.com/ajax/"]W3Schools … | |
Re: Try this, you were missing some semicolon's at the end of your lines: [b]paycheck.php:[/b] [CODE=php] <html> <head> <title>Paycheck Calculator</title> </head> <body> <?php if($_GET['submit']=="Submit"&&isset($_GET["hoursWorked"])&&isset($_GET["wagesRate"])) { echo "Your Paycheck is: <b>".($_GET["hoursWorked"] * $_GET["wagesRate"]) + (($_GET["hoursWorked"] - 40) * $_GET["wagesRate"] * 1.5)."</b><br/>\n<a href='paycheck.php'>Calculate Again</a>"; } else { echo "<form action='paycheck.php' method='get'>\n <label for='hoursWorked'>Hours … |
The End.