help me please


#1

i am trying to search my database for a make of car and have it return the findings and display them.

i have got the that is below but it only displays the code:

<?php $page_title ='For sale!'; include ('header.inc'); echo '

welcome to the sales part of teh website!

' ?> Search Postings:

$result = mysql("$users","SELECT * FROM $cars WHERE (Make ‘%$Search%’ OR Model ‘%$Search%’);

<?php include ('footer.inc'); ?>

please help me


#2

Unless you are using a templating system that I don’t know you are making a number mistakes. By the looks of it you are pretty new to PHP so…

I want you to go to http://www.codewalkers.com and check out the tutorials in the tutorials/basics section. You should check out the “Creating Dynamic Websites with PHP and MySQL” to get a handle on the accessing a database syntax (connect, select DB, query, fetch). It is all in there, just skip the parts where you are loading the software and creating the DB. Next I want you to check out the tutorial “Working with forms in PHP”. It will give all of the basic info.

If you have any questions about what is happening in the tutorials or simply need more clarification let us know. I beleive you can get a lot out of them.

Good luck!


#3

I learn best by seeing examples in action. Do they have any of that there? I saw this script:

[code]

File Upload
FILE >

[/code]

But I don’t exactly know how it works, or what to change to make it work on my site so I can see what it does.

Link:

http://codewalkers.com/tutorials/48/1.html


#4

Shrubwater - all that looks to be is a form to upload a file. I don’t understand what you are asking. I read the tutorial what is the problem?


#5

oops sorry, wrong document. This was the code I meant, and the question is, how does it know to link up to my database? In otherwords, If I have a mysql database located at http://www.shrubbase.com/cgi/ad?mysql, and I have a photo file to upload to it, do I need a field or table that will link to that photo?

I guess I’m still not sure how to set it up so I can upload said photo and then access it easily. I get parts of this Ok, but there are parts I’m missing.

<?php
if (($_FILES['file']['type'] == 'image/gif') &&
    ($_FILES['file']['size'] < 5000))
{
    echo 'Return Code: ' . $_FILES['file']['error'] . '<br />';
    echo 'Uploading ' . $_FILES['file']['name'] . ' (' .
         $_FILES['file']['type'] . ', ' .
         ceil($_FILES['file']['size'] / 1024) . ' Kb).<br />';
    echo 'File is temporarily stored as ' . $_FILES['file']['tmp_name'];
}
else
{
    echo 'Sorry, we only accept .gif images under 5Kb for upload.';
}
?> 

#6

Shrubwater- I think your looking at the wrong tutorial for what you want to do. I found this in the database section “Storing Images in Database by Hermawan Haryanto” ( http://codewalkers.com/tutorials/35/1.html ). I read the first couple pages and it shows you how to upload and store an image to the database. I think that is more in line for what you want.

Good luck and let us know if we need to explain anything.


#7

Thank you for the help. I will do some more reading and let you know how it turns out. I have a lot to learn.