Jump to content

maxim

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

maxim's Achievements

Member

Member (2/5)

0

Reputation

  1. any takers ? still cant work this one out
  2. for whatever reason i think the problem is with PDO.
  3. i can var_dump the database handle (connection) and it is definatly there. the database hande is within the same scope. i dont even have any user defined functions at all. im using SQLite not MySQL and PDO for databse access/abstration. sorry i should have said that before. it is a update query. it updates 1 row and returns the number of rows effected. in my case it returns nothing, however if i remove these lines form the code i posted $sql = "SELECT * FROM posts WHERE id = '".$_GET['id']."';"; $result = $db_handle->query($sql); $selected_post = $result->fetch(); then it will return 1, meaning that it works. i however need to run BOTH querys. the first query populates a HTML form with a record from the database and works fine the second query UPDATES the record with the information the user types(edits) in the html form. it is this query that dose not work. is only works if i remove the first. which i cant do as i need the form feild populated so the data can be edited.
  4. it just echos the SQL statement, just to see if the submit button works which it dose because it echos teh SQL string. remove the echo nothing happens this is the line that wont work $db_handle->exec($edit); now if i remove the following code from what i posted. $sql = "SELECT * FROM posts WHERE id = '".$_GET['id']."';"; $result = $db_handle->query($sql); $selected_post = $result->fetch(); then this line $db_handle->exec($edit); WILL work. my question is why or at least how do i get it to work ?
  5. interesting, i did as you suggested putting the UPDATE condition statement out side the SELECT condition, with the same results, the code works the same when it is nested or outside. so im still at square 1. its defiantly possible to have a GET and POST at the same time. i have a delete query which works this way.
  6. no it wont, the echo is simply there as i stated in my first post to see if any code will work after a user presses the submit button. the echo simply echos the sting. the string is still a vaild and working SQL statement. it just wont get executed while the above SELECT statement is there
  7. i use PHP5's PDO for database access/abstration query returns a result set. (select statments where you want to see what has been returned) exec just returns the number of rows effected by your query. (Its a UPDATE query so i dont do the query method because i dont need anything returned) i also removed the ";" from the end of the SQL statements. but this didnt seem to do anything. thanks for the suggestions tho.
  8. im pretty baffed by this problem im having. Basicly i have a script which displays a entry from a database. i then call that same database record again so i can display it in a HTML form. now the code works the values of the database record get displayed in a text feild and text area of this form (so the user can edit its content). however when the submit button gets pressed the query to update the record never gets executed. to make sure the code is being run when the user presses the submit button i put and echo statement. and sure enough the button works and it echos the sting to the screen. the problem is the the UPDATE sql statement never happens. now if i take the SELECT statement,query call and fetch call and remove it from this code. the UPDATE statement will work. so my question is WHY ? why cant i execute 2 calls to my database ? <?php if ($_GET['action'] == 'edit') { $sql = "SELECT * FROM posts WHERE id = '".$_GET['id']."';"; $result = $db_handle->query($sql); $selected_post = $result->fetch(); //<input type="text" name="title" value=" $selected_post['title']"/> (this form is in an include) // submit button code // (this form is in an include and is there for edited its fine tho) if ($_POST['submit'] == true) { //this line echos just fine echo $edit = "UPDATE posts SET title='".$_POST['title']."',content='".$_POST['content']."',author_id=1,page='".$_POST['pages']."' WHERE id=".$_GET['id'].";"; //this db query never gets called it wont work (it will work when the previous slect query is removed however) $db_handle->exec($edit); } } ?>
  9. you can use output buffering, and to it with text like using dots for example. check out hudzilla.org
  10. easy just use file_get_contents, and it will put a local or a remote file in one big string.
  11. take a look at PHP's exec(); function
  12. maby in your parent class use a accessor method ie (set and get method) to set your data members. and then extend the parent class with a subclass. and access them through the subclass which would extend the patent class through inheritance. now you could set up a constructor in you parent class to set your data members OR just invoke your methods to set them so they can be accessed. failing that maby read up on OOP more in depth
  13. in my opinion the best book for bigginers is the one thorpe is talking about. http://www.hudzilla.org/php/ theres a slightly updated wiki version of this book. but i find it hard to read and like the one i linked better. its not like its out of date or anything
  14. i fixex the problem by useing and absolute path to the sqlite db. eg c:\model\database.sqlite. im also now using PDO instead of direct sqlite calls.
  15. long story shot my problem is with PHP5's built in "sqlite_open" function. basically im teaching my self PHP. and after getting to build a complex web site which got messy with procedural programming. to better understand OOP i a using a Model / View / Controller approach. not really using a "framework" at all just doing it my self. now on to the problem. i got 3 folders. model, View and controller. in my model i have a class that connects to a sqlite database and returns the database handle i have a class im my controller folder that need to manipulate that database so it uses the handle that the model provides. naturally i use includes. to include my model class's but because there is no data base in the controllers folder. the "sqlite_open" creates a NEW database if it cant connect to one. so basically i have a database with no tables. i cant put all my files in the "model" folder it kinda defeats the whole MVC way of thinking. so how where so i got from here ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.