-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Create a .php script with a phpinfo(); statement and browse to it to find out what version is running. You might have php5, but the version where you are running your code is not.
-
You are using php5 OOP syntax on a php4 system. The end of life of php4 was several years ago. It is long past time to upgrade to php5.
-
You managed to miss-spell construct
-
Do you have display_errors set to ON as well?
-
The code that was posted somehow ended up with a in the links instead of a & and won't work. You would need to fix the HTML in the link.
-
This code is not IE compatibe (shocker I know)!
PFMaBiSmAd replied to pioneerx01's topic in PHP Coding Help
After you form the $sql variable in your code - echo $sql; -
Since the OP is already using mysqli, it would probably be a good idea to use mysqli functions for the remainder of the code.
-
This code is not IE compatibe (shocker I know)!
PFMaBiSmAd replied to pioneerx01's topic in PHP Coding Help
I don't see yet where you echoed the query in $sql so that you know what your query actually is as that would help determine why it doesn't match anything. -
Not intentionally picking on you, but we only see the information that is supplied in posts and any code that is posted in a reply is just an example that shows how you might do something and comes with an implied disclaimer that it may or may not have been tested, could contain typos, syntax errors, logic errors, other oversights, and may or may not be suitable for any particular purpose. There's no guarantee expressed or implied and your actual mileage may vary.
-
You would generally use the mysql IN() operator to match a column with several values - http://dev.mysql.com/doc/refman/5.1/en/comparison-operators.html#function_in You would produce the string used in the IN(...) by imploding the array of selected values. <?php $_GET['genre'][] = 'rock'; // simulate some data $_GET['genre'][] = 'pop'; $_GET['genre'][] = 'dance'; $genres = "'".implode("','",$_GET['genre'])."'"; $query = "SELECT * FROM your_table WHERE genre IN($genres)"; echo $query; ?>
-
Setting and referencing class variables are some of the basics you should know before attempting to use a class. This has nothing to do with using PDO in an object - <?php class fetcher { private $pdo; // class variable for PDO object function __construct($db){ $this->pdo = $db; // save the passed $db parameter into the class variable } function grab_tasks($userid){ $grabber = $this->pdo->query('SELECT * WHERE user_id =' . $userid); // reference the ->query() method of the class variable .... } } // instance of your db class $db = new PDO("mysql:host=localhost;dbname=database", "root", "root"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // instance of your class $what_ever = new fetcher($db); // pass the db object into the instance of your class. ?>
-
MYSQL error: column count doesn't match vakue count at row
PFMaBiSmAd replied to mark103's topic in PHP Coding Help
LOL, none of the code/errors posted together match. mark103, you cannot (successfully) write code by randomly changing things. You must know what you are changing and why you are changing it (you don't even have a names parameter in the URL, so the $_GET[names] you used in the last code you posted doesn't even exist) and you must read what the error messages are telling you. -
There's also no point in executing the same exact query over and over inside of a loop. The result will be exactly the same each time the query is executed.
-
You should probably check with your web host if and how they permit you to change the upload_max_filesize and post_max_size settings on their server.
-
Here is an example - <?php function showMonth($month, $year, $data) { $date = mktime(12, 0, 0, $month, 1, $year); $daysInMonth = date("t", $date); $offset = date("w", $date); $rows = 1; echo "<h1>Displaying calendar for " . date("F Y", $date) . "</h1>\n"; echo "<table border=\"1\">\n"; echo "\t<tr><th>Su</th><th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th></tr>"; echo "\n\t<tr>"; for($i = 1; $i <= $offset; $i++) { echo "<td></td>"; } for($day = 1; $day <= $daysInMonth; $day++) { if( ($day + $offset - 1) % 7 == 0 && $day != 1) { echo "</tr>\n\t<tr>"; $rows++; } // The original line of code: echo "<td>" . $day ."</td>"; was changed to the following 10 lines $cur_date = sprintf('%04d-%02d-%02d',$year,$month,$day); // format date as YYYY-MM-DD if(!isset($data[$cur_date])){ echo "<td>" . $day ."</td>"; } else { echo "<td class=\"has_data\" onMouseover=\"ddrivetip('{$data[$cur_date]}','yellow', 100)\" onMouseout=\"hideddrivetip()\" >" . $day ."</td>"; unset($data[$cur_date]); // remove the data from the array } } while( ($day + $offset) <= $rows * 7) { echo "<td></td>"; $day++; } echo "</tr>\n"; echo "</table>\n"; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>Calendar</title> <style type="text/css"> td.has_data {background-color:orange;} #dhtmltooltip{ position: absolute; width: 150px; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135); } </style> </head> <body> <div id="dhtmltooltip"></div> <script type="text/javascript"> /*********************************************** * Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ var offsetxpoint=-60 //Customize x offset of tooltip var offsetypoint=20 //Customize y offset of tooltip var ie=document.all var ns6=document.getElementById && !document.all var enabletip=false if (ie||ns6) var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "" function ietruebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function ddrivetip(thetext, thecolor, thewidth){ if (ns6||ie){ if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px" if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor tipobj.innerHTML=thetext enabletip=true return false } } function positiontip(e){ if (enabletip){ var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft; var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop; //Find out how close the mouse is to the corner of the window var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20 var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20 var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000 //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<tipobj.offsetWidth) //move the horizontal position of the menu to the left by it's width tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px" else if (curX<leftedge) tipobj.style.left="5px" else //position the horizontal position of the menu where the mouse is positioned tipobj.style.left=curX+offsetxpoint+"px" //same concept with the vertical position if (bottomedge<tipobj.offsetHeight) tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px" else tipobj.style.top=curY+offsetypoint+"px" tipobj.style.visibility="visible" } } function hideddrivetip(){ if (ns6||ie){ enabletip=false tipobj.style.visibility="hidden" tipobj.style.left="-1000px" tipobj.style.backgroundColor='' tipobj.style.width='' } } document.onmousemove=positiontip </script> <?php $data = array(); // get or generate some data to add to the calendar $data['2011-01-02'] = 'something'; $data['2011-01-20'] = 'else'; showMonth(1, 2011, $data); // Jan, 2011 ?> </body> </html> The showMonth() function was something I found, modified to accept the $data array when it was called and ~ 10 lines were added (see the commented section in the function) to handle the display of the data in the correct date cell. Some css was used to set the background color of cells with data. A dynamic drive tool tip script was used to display the data on mouse over. The php code near the end simply gets some data into an array and calls the showMonth() function.
-
You need to use a good programming editor that allows you to save the file as a UTF-8 encoded WITHOUT the BOM or just save the file as an ANSI encoded file.
-
From the mysql documentation (Literal values/Strings)- Edit: And double single-quotes are treated as a literal single-quote in a string, depending on what and where you are doing this.
-
This code is not IE compatibe (shocker I know)!
PFMaBiSmAd replied to pioneerx01's topic in PHP Coding Help
I recommend that you echo the $sql variable so that you can see exactly what your query is. I suspect that register_globals are on and you have either a session variable or a cookie variable (that is only set in IE) with the same name as one of your post/get variables from the form. -
This code is not IE compatibe (shocker I know)!
PFMaBiSmAd replied to pioneerx01's topic in PHP Coding Help
Any chance your form is using an image as a submit button (or has some invalid HTML in it that FF is ignoring the error in, but IE is not)? Edit: I either need to read faster, type faster, or hit the post button faster.... -
And the double-quote should be at the end of the query string, not after the or die() statement. Actually, the or die() shouldn't even be part of that statement because you are assigning a string to $blogQ
-
MYSQL error: column count doesn't match vakue count at row
PFMaBiSmAd replied to mark103's topic in PHP Coding Help
Edit: LOL again. I recommend that you echo $sql as part of your die() error handling so that you can see exactly what the query is. I don't think that is the code and/or the query that is failing. @sooner, those aren't quotes. They are back-ticks (yes it matters what they are.) -
Someone already stated you would need to store it in a class variable -
-
You would generally just pass the $db object into your class when you create an instance of your class. In your class constructor, store it in a class variable that you can then reference in any of the methods in your class - $what_ever = new fetcher($db); // pass the db object into the instance of your class.
-
It would really help if you showed the code between those two points. If $db is not defined, you are either un-setting it or you have a variable scope problem.
-
The total size of all the files is probably exceeding the post_max_size setting - http://us.php.net/manual/en/ini.core.php#ini.post-max-size